[英]Reading Multiple JSON objects in java
{"phone":1234,"name":"rose","key":1,"country":"india"}
{"phone":6789,"name":"jasmine","key":2,"country":"india"}
while reading this type of json data,I'm getting this error:在读取这种类型的 json 数据时,我收到此错误:
Unexpected token LEFT BRACE({) at position 54.
at org.json.simple.parser.JSONParser.parse(JSONParser.java:146)
at org.json.simple.parser.JSONParser.parse(JSONParser.java:92)
Could anyone please help me resolve this error?谁能帮我解决这个错误?
You seem to have 2 lines of JSON.您似乎有 2 行 JSON。 Each line is a valid JSON object/document in of itself, however if you pass both lines together then it would not be a valid JSON document.
每行本身都是一个有效的 JSON 对象/文档,但是如果将两行一起传递,那么它将不是一个有效的 JSON 文档。 Your options are
你的选择是
Read each line as a separate entry and invoke the JSON parser on that line to produce a JSON object.将每一行作为一个单独的条目读取,并在该行上调用 JSON object 解析器。
Use an array to process both lines:使用数组来处理这两行:
[ {"phone":1234,"name":"rose","key":1,"country":"india"}, {"phone":6789,"name":"jasmine","key":2,"country":"india"} ] [ {“电话”:1234,“姓名”:“玫瑰”,“钥匙”:1,“国家”:“印度”},{“电话”:6789,“姓名”:“茉莉花”,“钥匙”: 2,"国家":"印度"} ]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.