2016-10-02 6 views
-4

jsonデータの読み取りに問題があります。私はいくつかの方法を試みましたが、短くなりました。どんな助けも歓迎です。コードは次のとおりです。Jsonがリストからデータを取得しない

これはファイル全体で修正されました。

"gallery": { 
      "106x100": [ 
      "106x100-0.jpeg", 
      "106x100-1.jpeg", 
      "106x100-2.jpeg", 
      "106x100-3.jpeg", 
      "106x100-4.jpeg", 
      "106x100-5.jpeg", 
      "106x100-6.jpeg", 
      "106x100-7.jpeg", 
      "106x100-8.jpeg", 
      "106x100-9.jpeg", 
      "106x100-10.jpeg", 
      "106x100-11.jpeg", 
      "106x100-12.jpeg", 
      "106x100-13.jpeg", 
      "106x100-14.jpeg", 
      "106x100-15.jpeg", 
      "106x100-16.jpeg" 
      ], 
      "190x100": [ 
      "190x100-0.jpeg", 
      "190x100-1.jpeg", 
      "190x100-2.jpeg", 
      "190x100-3.jpeg", 
      "190x100-4.jpeg", 
      "190x100-5.jpeg", 
      "190x100-6.jpeg", 
      "190x100-7.jpeg", 
      "190x100-8.jpeg", 
      "190x100-9.jpeg", 
      "190x100-10.jpeg", 
      "190x100-11.jpeg", 
      "190x100-12.jpeg", 
      "190x100-13.jpeg", 
      "190x100-14.jpeg", 
      "190x100-15.jpeg", 
      "190x100-16.jpeg" 
      ] 
     }, 
     }, 
+0

jsonを読むためにどのような言語を使用しますか? –

+0

私はJavaを使用しています – zomlaaa95

+0

@ zomlaaa95:あなたが書き留めたコードを共有して、修正するものを教えてください。 – Nishit

答えて

2

jsonの形式が間違っています。

{"190x100": [ 
      "190x100-0.jpeg", 
      "190x100-1.jpeg", 
      "190x100-2.jpeg", 
      "190x100-3.jpeg", 
      "190x100-4.jpeg", 
      "190x100-5.jpeg", 
      "190x100-6.jpeg", 
      "190x100-7.jpeg", 
      "190x100-8.jpeg", 
      "190x100-9.jpeg", 
      "190x100-10.jpeg", 
      "190x100-11.jpeg", 
      "190x100-12.jpeg", 
      "190x100-13.jpeg", 
      "190x100-14.jpeg", 
      "190x100-15.jpeg", 
      "190x100-16.jpeg" 
      ]} 

PS:あなたは、Javaを使用している読む

はここで正しいフォーマットです。これを試すことができます:

String jsonString = "{"+json+"}"; //pass json here if you are getting it in that format. 
    JSONObject jsonObject = new JSONObject(jsonString); 
    JSONObject newJSON = jsonObject.getJSONObject("gallery"); 
    System.out.println(newJSON.toString()); 

もう一度形式が間違っています。

{"gallery": { 
      "106x100": [ 
      "106x100-0.jpeg", 
      "106x100-1.jpeg", 
      "106x100-2.jpeg", 
      "106x100-3.jpeg", 
      "106x100-4.jpeg", 
      "106x100-5.jpeg", 
      "106x100-6.jpeg", 
      "106x100-7.jpeg", 
      "106x100-8.jpeg", 
      "106x100-9.jpeg", 
      "106x100-10.jpeg", 
      "106x100-11.jpeg", 
      "106x100-12.jpeg", 
      "106x100-13.jpeg", 
      "106x100-14.jpeg", 
      "106x100-15.jpeg", 
      "106x100-16.jpeg" 
      ], 
      "190x100": [ 
      "190x100-0.jpeg", 
      "190x100-1.jpeg", 
      "190x100-2.jpeg", 
      "190x100-3.jpeg", 
      "190x100-4.jpeg", 
      "190x100-5.jpeg", 
      "190x100-6.jpeg", 
      "190x100-7.jpeg", 
      "190x100-8.jpeg", 
      "190x100-9.jpeg", 
      "190x100-10.jpeg", 
      "190x100-11.jpeg", 
      "190x100-12.jpeg", 
      "190x100-13.jpeg", 
      "190x100-14.jpeg", 
      "190x100-15.jpeg", 
      "190x100-16.jpeg" 
      ] 
     } 
     } 
+0

それは間違っていない、それはファイルの一部です。 – zomlaaa95

+0

@ zomlaaa95 json全体を投稿してください。 –

+0

@ zomlaaa95はjson形式を再度修正しました。 –

関連する問題