什么“JSON标准只允许一个顶级值”? [英] What does "JSON standard only allows one top level value"?

查看:3890
本文介绍了什么“JSON标准只允许一个顶级值”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的IntelliJ编辑器中,我有一个test.json文件,如下所示。第二个json记录显示错误消息Json标准仅允许一个顶级值。但这是一个有效的JSON文件,对吧?如何摆脱这个恼人的消息?

In my IntelliJ editor, I have a test.json file as below. The second json record displays an error message "Json standard only allows one top-level value". But this is a valid JSON file, right? How to get rid of this annoying message?

{"reviewerID": "A2XVJBSRI3SWDI", "asin": "0000031887", "reviewerName": "abigail", "helpful": [0, 0], "title": "Ballet Dress-Up Fairy Tutu", "url": "http://rads.stackoverflow.com/amzn/click/0000031887", "brand": "Boutique Cutie", "reviewText": "Perfect red tutu for the price. I baught it as part of my daughters Halloween costume and it looked great on her.", "overall": 5.0, "summary": "Nice tutu", "unixReviewTime": 1383523200, "reviewTime": "11 4, 2013"}
{"reviewerID": "A2G0LNLN79Q6HR", "asin": "0000031887", "reviewerName": "aj_18 \"Aj_18\"", "helpful": [1, 1], "title": "Ballet Dress-Up Fairy Tutu", "url": "http://rads.stackoverflow.com/amzn/click/0000031887", "brand": "Boutique Cutie", "reviewText": "This was a really cute tutu the only problem is that it was super short on my 5 yr old daughter. Other than that it was really adorable.", "overall": 4.0, "summary": "Really Cute but rather short.", "unixReviewTime": 1337990400, "reviewTime": "05 26, 2012"}


推荐答案

如果要在同一个json文件中使用它们,则必须将它们组合为[{Obj 1},{Obj 2}]。否则json文件将包含两个字典对象,它只能有一个顶级对象。

You have to combine them as [ {Obj 1}, {Obj 2} ] if you want to use them in the same json file. Otherwise the json file will be containing two dictionary objects and it can only have one top level object.

这篇关于什么“JSON标准只允许一个顶级值”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆