2017-02-21 14 views
1

にネストされたJSON配列を変換します助けてください私。ちょうどJavaの配列を作る。私は私が「用量」の配列を含む、Javaの配列からすべての要素を取得するようにJavaクラスタイプの配列やAndroidにJSON配列を変換したいの下に掲示JSON配列を持つJava配列

[ 
    { 
     "_id":"58299a0ae1053c391fb95026", 
     "legacy_ID":3014545, 
     "name":"OLMESAN 20 MG TAB", 
     "code":"OLMESAN.", 
     "default_sales_price":8, 
     "default_purchase_price":6, 
     "box_quantity":30, 
     "foreign":false, 
     "__v":0, 
     "creation_info":{ 
     "creation_time":"2016-11-14T11:03:38.413Z" 
     }, 
     "item_type":[ 
     { 
      "sub_item_type_no":"4", 
      "name":"TABLET", 
      "legacy_ID":"1061", 
      "creation_info":{ 
       "creation_time":"2016-11-14T05:45:12.548Z" 
      }, 
      "_id":"58294f68c08d0b186e467d9f", 
      "__v":"0" 
     } 
     ], 
     "route":[ 
     { 
      "name":"ORAL", 
      "legacy_ID":"1001", 
      "creation_info":{ 
       "creation_time":"2016-11-09T12:08:15.472Z" 
      }, 
      "active":"true", 
      "_id":"582311af5da26741ab82a00f", 
      "__v":"0" 
     } 
     ], 
     "manufacturer":[ 
     { 
      "other_name":"Beximco Pharma", 
      "name":"BEXIMCO PHARMACEUTICALS LTD", 
      "legacy_ID":"3000018", 
      "creation_info":{ 
       "creation_time":"2016-11-12T08:41:39.229Z" 
      }, 
      "active":"true", 
      "_id":"5826d5c379520725a8e05350", 
      "__v":"0" 
     } 
     ], 
     "pack":null, 
     "uom":[ 
     { 
      "name":"PIECE", 
      "legacy_ID":"10014", 
      "creation_info":{ 
       "creation_time":"2016-11-09T12:01:25.858Z" 
      }, 
      "_id":"58231015f37a2140e437eeaa", 
      "__v":"0" 
     } 
     ], 
     "generic":null, 
     "doses":[ 
     { 
      "en":"1 tab at noon - (after meals) - to continue.", 
      "bn":"১ বড়ি দুপুরে - (আহারের পর) - চলবে।", 
      "is_default":true, 
      "_id":"582815348bc48212898f63b8" 
     } 
     ] 
    }, 
    { 
     "_id":"58299a0ae1053c391fb95026", 
     "legacy_ID":3014545, 
     "name":"OLMESAN 20 MG TAB", 
     "code":"OLMESAN.", 
     "default_sales_price":8, 
     "default_purchase_price":6, 
     "box_quantity":30, 
     "foreign":false, 
     "__v":0, 
     "creation_info":{ 
     "creation_time":"2016-11-14T11:03:38.413Z" 
     }, 
     "item_type":[ 
     { 
      "sub_item_type_no":"4", 
      "name":"TABLET", 
      "legacy_ID":"1061", 
      "creation_info":{ 
       "creation_time":"2016-11-14T05:45:12.548Z" 
      }, 
      "_id":"58294f68c08d0b186e467d9f", 
      "__v":"0" 
     } 
     ], 
     "route":[ 
     { 
      "name":"ORAL", 
      "legacy_ID":"1001", 
      "creation_info":{ 
       "creation_time":"2016-11-09T12:08:15.472Z" 
      }, 
      "active":"true", 
      "_id":"582311af5da26741ab82a00f", 
      "__v":"0" 
     } 
     ], 
     "manufacturer":[ 
     { 
      "other_name":"Beximco Pharma", 
      "name":"BEXIMCO PHARMACEUTICALS LTD", 
      "legacy_ID":"3000018", 
      "creation_info":{ 
       "creation_time":"2016-11-12T08:41:39.229Z" 
      }, 
      "active":"true", 
      "_id":"5826d5c379520725a8e05350", 
      "__v":"0" 
     } 
     ], 
     "pack":null, 
     "uom":[ 
     { 
      "name":"PIECE", 
      "legacy_ID":"10014", 
      "creation_info":{ 
       "creation_time":"2016-11-09T12:01:25.858Z" 
      }, 
      "_id":"58231015f37a2140e437eeaa", 
      "__v":"0" 
     } 
     ], 
     "generic":null 
    } 
] 
+1

なぜuがGSONを使用していませんか? – Dilip

+0

arrylistとgetterセッターを持つモーダルクラスを使用 –

+1

[JSONをAndroidで解析する方法]の複製可能性(http://stackoverflow.com/questions/9605913/how-to-parse-json-in-android) –

答えて

0
ArrayList<String> list = new ArrayList<String>();  
JSONArray jsonArray = (JSONArray)jsonObject; 
if (jsonArray != null) { 
    int len = jsonArray.length(); 
    for (int i=0;i<len;i++){ 
    list.add(jsonArray.get(i).toString()); 
    } 
} 
+0

jsson – lockman

関連する問題