自由之牛
2013-11-06 03:19
采纳率: 100%
浏览 12.7k

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");

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 程序员七猫 2014-01-07 04:30
    已采纳

    {
    "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
    然后根据提示更改哦

    打赏 评论
  • JaveZh 2013-11-06 05:59

    "data":"[
    改成:"data":[ 同样结尾的"也去掉

    打赏 评论
  • 自由之牛 2014-01-17 08:07

    谢谢了。 非常感谢。

    打赏 评论

相关推荐 更多相似问题