我有一个json数组发布在下面我想将json数组转换为java类Type数组或android以便我从java中的数组中获取所有元素,包括“剂量”数组请帮助我。只需制作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
}
]
答案 0 :(得分: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());
}
}