2017-12-04 4 views
-1

私はjson構文解析の初心者です。私は通常のjsonオブジェクトを解析する方法を知っていますが、以下にリストしているjsonの種類を解析する方法はわかりません。誰かが私にこれを助けることができますか?別の種類のjsonオブジェクトを解析して、recyclerviewのデータをリストしてください。

私は、JSON

[{"id":"1","image_title":"Android 1.5 Cupcake","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"2","image_title":"Android 1.6 Donut","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"3","image_title":"Android 2.0 Eclair","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"4","image_title":"Android 2.2 Froyo","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"5","image_title":"Android 2.3 GingerBread","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"6","image_title":"Android 3.0 HoneyComb","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"7","image_title":"Android 4.0 Ice Cream Sandwich","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"8","image_title":"Android 4.1 Jelly Bean","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"},{"id":"9","image_title":"Android 4.4 KitKat","image_url":"https://firebasestorage.googleapis.com/v0/b/sukshichat.appspot.com/o/Wrangler%2FIMG_20171102_141451.jpg?alt=media&token=ce3f2747-a36f-416d-9dfc-ecfb6be4b447"}] 

のこの種を解析する方法を知っているしかし、私はこれを解析し、recyclerviewで値を追加する方法については考えています。

{ 
    "id": { 
     "0": "1", 
     "5": "2", 
     "6": "3", 
     "10": "4", 
     "12": "5" 
    }, 
    "image_title": { 
     "0": "Blue", 
     "5": "Black", 
     "6": "Yellow", 
     "10": "Orange", 
     "12": "Voilet" 
    } 
} 

私の完全なJSONレスポンス

{ 
    "Store EAN Number": { 
    "0": null, 
    "5": null, 
    "6": null, 
    "10": null, 
    "12": null 
    }, 
    "SKU Code": { 
    "0": null, 
    "5": null, 
    "6": null, 
    "10": null, 
    "12": null 
    }, 
    "Mihu EAN Number": { 
    "0": 9999922000001, 
    "5": 9999922000006, 
    "6": 9999922000007, 
    "10": 9999922000011, 
    "12": 9999922000013 
    }, 
    "Style Code": { 
    "0": "Vico0001", 
    "5": "Vico0006", 
    "6": "Vico0007", 
    "10": "Vico0011", 
    "12": "Vico0013" 
    }, 
    "Store": { 
    "0": "Vision Colour", 
    "5": "Vision Colour", 
    "6": "Vision Colour", 
    "10": "Vision Colour", 
    "12": "Vision Colour" 
    }, 
    "Store Code": { 
    "0": 22, 
    "5": 22, 
    "6": 22, 
    "10": 22, 
    "12": 22 
    }, 
    "Category": { 
    "0": "Shirt", 
    "5": "Shirt", 
    "6": "Shirt", 
    "10": "Shirt", 
    "12": "Shirt" 
    }, 
    "Gender": { 
    "0": "Male", 
    "5": "Male", 
    "6": "Male", 
    "10": "Male", 
    "12": "Male" 
    }, 
    "Sleeves Type": { 
    "0": "Full Sleeve", 
    "5": "Full Sleeve", 
    "6": "Full Sleeve", 
    "10": "Full Sleeve", 
    "12": "Full Sleeve" 
    }, 
    "Collection": { 
    "0": "Casual", 
    "5": "Casual", 
    "6": "Casual", 
    "10": "Casual", 
    "12": "Casual" 
    }, 
    "Fitting Type": { 
    "0": "Slim", 
    "5": "Slim", 
    "6": "Slim", 
    "10": "Slim", 
    "12": "Slim" 
    }, 
    " Size ": { 
    "0": "M", 
    "5": "M", 
    "6": "M", 
    "10": "M", 
    "12": "M" 
    }, 
    "Pocket Type": { 
    "0": "No Pocket", 
    "5": "V Shape", 
    "6": "V Shape", 
    "10": "V Shape", 
    "12": "V Shape" 
    }, 
    "Fabric Type": { 
    "0": "100% cotton", 
    "5": "100% cotton", 
    "6": "100% cotton", 
    "10": "100% cotton", 
    "12": "100% cotton" 
    }, 
    "Colour": { 
    "0": "White", 
    "5": "White", 
    "6": "White", 
    "10": "White", 
    "12": "White" 
    }, 
    "Fabric Design": { 
    "0": "Printed", 
    "5": "Printed", 
    "6": "Printed", 
    "10": "Printed", 
    "12": "Printed" 
    }, 
    "garment_description": { 
    "0": null, 
    "5": null, 
    "6": null, 
    "10": null, 
    "12": null 
    }, 
    "garment_name": { 
    "0": "White Full Sleeve Printed Shirt", 
    "5": "White Full Sleeve Printed Shirt", 
    "6": "White Full Sleeve Printed Shirt", 
    "10": "White Full Sleeve Printed Shirt", 
    "12": "White Full Sleeve Printed Shirt" 
    }, 
    "mrp_price": { 
    "0": 450, 
    "5": 450, 
    "6": 450, 
    "10": 450, 
    "12": 450 
    }, 
    "discount_price": { 
    "0": null, 
    "5": null, 
    "6": null, 
    "10": null, 
    "12": null 
    } 

} 
+0

[アンドロイド、リストビュー上のWebサーバとディスプレイからの解析JSONデータ]の可能性のある重複した(HTTPS:/ /stackoverflow.com/questions/36221795/android-parse-json-data-from-a-web-server-and-display-on-listview) – ADM

+0

上記の最初のすべてはjsonarrayではありません。 – Dilip

+0

は、0,5,6,10,12のようなキーがidとimage_titleまたは動的キーの中の静的なキーであることを教えてくれます。またはそれらが変更されます – Pratap

答えて

0

このような解析:

JsonObject jsonObj = new JsonObject(response); 

JsonObject id_jsonObj = jsonObj.getJsonObject("id"); 

String first = id_jsonObj.getString("0"); 

String second = id_jsonObj.getString("5"); 

//and so on 

JsonObject image_jsonObj = jsonObj.getJsonObject("image_title"); 

String title1 = image_jsonObj.getString("0"); 

String title2 = image_jsonObj.getString("5"); 

//and so on 
+0

IDの0,5は、常に同じではありません。それらを動的に取得する方法を説明することができます – Stackover67

+0

あなたはこのようなidを得ることができます: JSONArray names = id_jsonObj.names(); Log.e( "names"、names.getString(i)); for(int i = 0; i rastha67

関連する問題