I have problem with converting json string to Json Object
我有将json字符串转换为Json对象的问题
I Receive this Json Result from my server :
我从我的服务器收到这个Json结果:
{"type":"news","items":[{"id": "867","title": "مخيّم_بساط_الرّيح - مخيّم_كان_ياما_كان","content": " في المركز الجماهيري ابوسنان .. اليوم الخامس على التوالي .. ","fromDate": false,"toDate": false,"image": "productImages2/105/2017/07/13/image1499940076.jpg","imageAlt": "مخيّم_بساط_الرّيح - مخيّم_كان_ياما_كان","exLink":"http://www.mas.org.il/page.php?type=page&id=2477&ht=#navbar","price": false}]}
and I want to put the result into list view
我想把结果放到列表视图中
I have tried many methods which eventually failed
我尝试了很多最终失败的方法
2 个解决方案
#1
0
simply you can take that received string as string and then convert it
只需将接收到的字符串作为字符串然后转换即可
String json ={"type":"news","items":[{"id": "867","title": "مخيّم_بساط_الرّيح - مخيّم_كان_ياما_كان","content": " في المركز الجماهيري ابوسنان .. اليوم الخامس على التوالي .. ","fromDate": false,"toDate": false,"image": "productImages2/105/2017/07/13/image1499940076.jpg","imageAlt": "مخيّم_بساط_الرّيح - مخيّم_كان_ياما_كان","exLink":"http://www.mas.org.il/page.php?type=page&id=2477&ht=#navbar","price": false}]}
and now convert in json object
现在转换为json对象
JSONObject jsonObj = new JSONObject(json);
now you can use it as jsonobject
现在你可以将它用作jsonobject
#2
0
Try this
JSONObject jsonObj = new JSONObject(json);
JSONArray jsonArry = jsonObj.getJSONArray("items");
JSONObject jsonObj1 = jsonArry.getJSONObject(0);
String id = jsonObj1.getString("id");
String title= jsonObj1.getString("title");
..
..
..
String price = jsonObj1.getString("price");
#1
0
simply you can take that received string as string and then convert it
只需将接收到的字符串作为字符串然后转换即可
String json ={"type":"news","items":[{"id": "867","title": "مخيّم_بساط_الرّيح - مخيّم_كان_ياما_كان","content": " في المركز الجماهيري ابوسنان .. اليوم الخامس على التوالي .. ","fromDate": false,"toDate": false,"image": "productImages2/105/2017/07/13/image1499940076.jpg","imageAlt": "مخيّم_بساط_الرّيح - مخيّم_كان_ياما_كان","exLink":"http://www.mas.org.il/page.php?type=page&id=2477&ht=#navbar","price": false}]}
and now convert in json object
现在转换为json对象
JSONObject jsonObj = new JSONObject(json);
now you can use it as jsonobject
现在你可以将它用作jsonobject
#2
0
Try this
JSONObject jsonObj = new JSONObject(json);
JSONArray jsonArry = jsonObj.getJSONArray("items");
JSONObject jsonObj1 = jsonArry.getJSONObject(0);
String id = jsonObj1.getString("id");
String title= jsonObj1.getString("title");
..
..
..
String price = jsonObj1.getString("price");