如何在android中的JSON解析中为json数组内的Json数组编写代码?
我在编写以下json解析功能时遇到问题..请问有谁可以帮我解决android中的代码问题?
我的json数据是
{
"error": "0",
"message": "List of all instances",
"instance_list": [
[
{
"instance_uid": "1046",
"last_message": "",
"message_id": "m-563-1046-1442486965",
"msg_dir": "outgoing",
"order_id": "5",
"DishID": "",
"seller_uid": "",
"instance_name": "",
"login_user_image": ""
}
],
[
{
"instance_uid": "1046",
"last_message": "",
"message_id": "m-563-1046-1442486965",
"msg_dir": "outgoing",
"order_id": "5",
"DishID": "",
"seller_uid": "",
"instance_name": "",
"login_user_image": ""
}
]
{
"1": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-563-477-1442334018",
"msg_dir": "outgoing",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"2": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-563-477-1442333953",
"msg_dir": "outgoing",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"3": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-563-477-1442333861",
"msg_dir": "outgoing",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"4": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-477-563-1442333831",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"5": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-477-563-1442333249",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"6": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-563-477-1442302909",
"msg_dir": "outgoing",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"7": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-563-477-1442302748",
"msg_dir": "outgoing",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"8": {
"instance_uid": "477",
"last_message": "this is test message9 with orderid",
"message_id": "m-563-477-1442302439",
"msg_dir": "outgoing",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"9": {
"instance_uid": "477",
"last_message": "this is test message8 with orderid",
"message_id": "m-477-563-1442300668",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"10": {
"instance_uid": "477",
"last_message": "this is test message7 with orderid",
"message_id": "m-477-563-1442300657",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"11": {
"instance_uid": "477",
"last_message": "this is test message6 with orderid",
"message_id": "m-477-563-1442300645",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"12": {
"instance_uid": "477",
"last_message": "this is test message5 with orderid",
"message_id": "m-477-563-1442300633",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"13": {
"instance_uid": "477",
"last_message": "this is test message4 with orderid",
"message_id": "m-477-563-1442300620",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"14": {
"instance_uid": "477",
"last_message": "this is test message3 with orderid",
"message_id": "m-477-563-1442300608",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"15": {
"instance_uid": "477",
"last_message": "this is test message2 with orderid",
"message_id": "m-477-563-1442300596",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"16": {
"instance_uid": "477",
"last_message": "this is test message1 with orderid2",
"message_id": "m-477-563-1442300575",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"17": {
"instance_uid": "477",
"last_message": "this is test message with orderid1",
"message_id": "m-477-563-1442300555",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
},
"18": {
"instance_uid": "477",
"last_message": "this is test message with orderid",
"message_id": "m-477-563-1442300535",
"msg_dir": "incoming",
"order_id": "1",
"DishID": "",
"seller_uid": "",
"instance_name": "android",
"login_user_image": "http://sgappstore.com/not86/sites/default/files/styles/chat_user_94_x_94/public/1442298004.jpg?itok=iYaE3w-o"
}
},
[
{
"instance_uid": "183",
"last_message": "this is android test message",
"message_id": "m-463-464-1441088232",
"msg_dir": "outgoing",
"order_id": "0",
"DishID": "",
"seller_uid": "",
"instance_name": "",
"login_user_image": ""
},
{
"instance_uid": "183",
"last_message": "Hello how are you",
"message_id": "m-512-513-1441042356",
"msg_dir": "incoming",
"order_id": "0",
"DishID": "",
"seller_uid": "",
"instance_name": "",
"login_user_image": ""
},
{
"instance_uid": "183",
"last_message": "Hello how are you",
"message_id": "m-512-513-1441040916",
"msg_dir": "incoming",
"order_id": "0",
"DishID": "",
"seller_uid": "",
"instance_name": "",
"login_user_image": ""
}
]
]
}
答案 0 :(得分:1)
首先是编辑你的问题并删除一些json数据
请阅读这篇文章
https://stackoverflow.com/help/how-to-ask
第二个是读这个
http://www.json.org/javadoc/org/json/JSONObject.html
并发布您的错误和问题