开发者社区> 问答> 正文

这字符串json格式有问题,怎么转jsonarray的时候会报错? ?报错

字符串如下

 [{postUser:自由的翅膀,content:please,where do you find this picture?,dateTime:2016-12-14 12:29:286}]

把这字符串转jsonarray的时候就会抱错
JSONArray array=new JSONArray(str);

报错:

 org.json.JSONException: Expected a ':' after a key at character 64

我看不出这字符串的json格式哪里有问题,而且我生成这字符串也是用jsonobject,jsonarray来生成然后再toString()的,求指点

展开
收起
爱吃鱼的程序员 2020-06-23 13:42:55 864 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    wheredoyoufindthispicture?wheredoyoufindthispicture?这里你不是按json的格式来的
    你要“wheredoyoufindthispicture?:’‘”格式要配上啊

    参考格式:{"people":[

    {"firstName":"Brett","lastName":"McLaughlin","email":"aaaa"},

    {"firstName":"Jason","lastName":"Hunter","email":"bbbb"},

    {"firstName":"Elliotte","lastName":"Harold","email":"cccc"}

    ]}

    http://blog.csdn.net/taxiangwuhen/article/details/7849711
    http://www.bkjia.com/Javabc/1017059.html

    改成下面这样:

    [{"postUser":"自由的翅膀","content":"please,wheredoyoufindthispicture?","dateTime":"2016-12-1412:29:286"}]

    http://json.cn/

    检查或者格式化,可以用上面那个地址。

    这不是json字符格式,所以报错

    2020-06-23 13:43:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载