程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> 解析json數據-android 開發中 json解析問題出錯啊

解析json數據-android 開發中 json解析問題出錯啊

編輯:編程綜合問答
android 開發中 json解析問題出錯啊

{"msg":1,"msgbox":"返回歌手分類!","data":"[ { "rownum":"11","id":"1047","userName":"敖日格勒","picurl":"mobile1_1047_head.jpg"}, { "rownum":"12","id":"1046","userName":"敖根","picurl":"mobile1_1046_head.jpg"}, { "rownum":"13","id":"1045","userName":"阿拉騰孫德爾","picurl":"mobile1_1045_head.jpg"}, { "rownum":"14","id":"1044","userName":"阿拉騰松布爾","picurl":"mobile1_1044_head.jpg"}, { "rownum":"15","id":"1043","userName":"哈斯格組合","picurl":"mobile1_1043_head.jpg"}, { "rownum":"16","id":"1042","userName":"金花兒","picurl":"mobile1_1042_head.JPG"}, { "rownum":"17","id":"1041","userName":"李勝男","picurl":"mobile1_1041_head.jpg"}, { "rownum":"18","id":"1040","userName":"趙丹丹","picurl":"mobile1_1040_head.jpg"}, { "rownum":"19","id":"1039","userName":"張震宇","picurl":"mobile1_1039_head.jpg"}, { "rownum":"20","id":"1038","userName":"張曉燕","picurl":"mobile1_1038_head.jpg"}, { "rownum":"21","id":"1037","userName":"永勝","picurl":"mobile1_1037_head.jpg"} ]"}

JSONObject jsonObj = new JSONObject(strtest)
strtest就是上面的json格式字符串
就報錯 json格式不對麼。。。。
org.json.JSONException: Unterminated object at character 42 of。。。
JSONArray jsonObjs = new JSONObject(strtest).getJSONArray("data");

最佳回答:


{
"msg": 1,
"msgbox": "返回歌手分類!",
"data": [
{
"rownum": "11",
"id": "1047",
"userName": "敖日格勒",
"picurl": "mobile1_1047_head.jpg"
},
{
"rownum": "12",
"id": "1046",
"userName": "敖根",
"picurl": "mobile1_1046_head.jpg"
},
{
"rownum": "13",
"id": "1045",
"userName": "阿拉騰孫德爾",
"picurl": "mobile1_1045_head.jpg"
},
{
"rownum": "14",
"id": "1044",
"userName": "阿拉騰松布爾",
"picurl": "mobile1_1044_head.jpg"
},
{
"rownum": "15",
"id": "1043",
"userName": "哈斯格組合",
"picurl": "mobile1_1043_head.jpg"
},
{
"rownum": "16",
"id": "1042",
"userName": "金花兒",
"picurl": "mobile1_1042_head.JPG"
},
{
"rownum": "17",
"id": "1041",
"userName": "李勝男",
"picurl": "mobile1_1041_head.jpg"
},
{
"rownum": "18",
"id": "1040",
"userName": "趙丹丹",
"picurl": "mobile1_1040_head.jpg"
},
{
"rownum": "19",
"id": "1039",
"userName": "張震宇",
"picurl": "mobile1_1039_head.jpg"
},
{
"rownum": "20",
"id": "1038",
"userName": "張曉燕",
"picurl": "mobile1_1038_head.jpg"
},
{
"rownum": "21",
"id": "1037",
"userName": "永勝",
"picurl": "mobile1_1037_head.jpg"
}
]
}

這個是可以正常json解析的。。你可以把你的json復制到http://www.bejson.com/go.php?u=http://www.bejson.com/index.php
然後根據提示更改哦

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved