对JSON格式的详细操作
需要JSON格式的操作 我从twitterstream流式传输了这个JSON文件,但在检查JSONLint时,我发现以下错误对JSON格式的详细操作,json,Json,需要JSON格式的操作 我从twitterstream流式传输了这个JSON文件,但在检查JSONLint时,我发现以下错误 Error: Parse error on line 11: ...1554180840158" }} { "delete": { "st ---------------------^ Expecting 'EOF', '}', ',', ']', got '{' JSON代码:- { "delete": { "status":
Error: Parse error on line 11:
...1554180840158" }} { "delete": { "st
---------------------^
Expecting 'EOF', '}', ',', ']', got '{'
JSON代码:-
{
"delete": {
"status": {
"id": 1038195538020196352,
"id_str": "1038195538020196352",
"user_id": 1730046890,
"user_id_str": "1730046890"
},
"timestamp_ms": "1554180840158"
}
} {
"delete": {
"status": {
"id": 761199968916955136,
"id_str": "761199968916955136",
"user_id": 715099043609751552,
"user_id_str": "715099043609751552"
},
"timestamp_ms": "1554180840228"
}
}
这不是JSON——它是由一个空格分隔的两个JSON对象。您需要将它们放入阵列中:
[{
"delete": {
"status": {
"id": 1038195538020196352,
"id_str": "1038195538020196352",
"user_id": 1730046890,
"user_id_str": "1730046890"
},
"timestamp_ms": "1554180840158"
}
}, {
"delete": {
"status": {
"id": 761199968916955136,
"id_str": "761199968916955136",
"user_id": 715099043609751552,
"user_id_str": "715099043609751552"
},
"timestamp_ms": "1554180840228"
}
}]
这不是JSON——它是由一个空格分隔的两个JSON对象。您需要将它们放入阵列中:
[{
"delete": {
"status": {
"id": 1038195538020196352,
"id_str": "1038195538020196352",
"user_id": 1730046890,
"user_id_str": "1730046890"
},
"timestamp_ms": "1554180840158"
}
}, {
"delete": {
"status": {
"id": 761199968916955136,
"id_str": "761199968916955136",
"user_id": 715099043609751552,
"user_id_str": "715099043609751552"
},
"timestamp_ms": "1554180840228"
}
}]
JSONLint抱怨它不是有效的对象。实际上,JSON示例中有两个对象。每一个都通过JSONLT,但是您的错误与中间的“{{”有关。对于整个示例进行解析,您需要一个[在开始时,在两个对象中间的逗号,例如},{和a]。参见下面的
[{
"delete": {
"status": {
"id": 1038195538020196352,
"id_str": "1038195538020196352",
"user_id": 1730046890,
"user_id_str": "1730046890"
},
"timestamp_ms": "1554180840158"
}
}, {
"delete": {
"status": {
"id": 761199968916955136,
"id_str": "761199968916955136",
"user_id": 715099043609751552,
"user_id_str": "715099043609751552"
},
"timestamp_ms": "1554180840228"
}
}]
[{
"delete": {
"status": {
"id": 1038195538020196352,
"id_str": "1038195538020196352",
"user_id": 1730046890,
"user_id_str": "1730046890"
},
"timestamp_ms": "1554180840158"
}
}, {
"delete": {
"status": {
"id": 761199968916955136,
"id_str": "761199968916955136",
"user_id": 715099043609751552,
"user_id_str": "715099043609751552"
},
"timestamp_ms": "1554180840228"
}
}]
你发布的不是JSON,而是两个用空格分隔的JSON对象。你发布的不是JSON,而是两个用空格分隔的JSON对象。谢谢Jamie,我现在知道了。因此,twitter不是将整个文件作为JSON发送,而是将多个JSON对象捆绑在一起发送。谢谢Jamie,我现在知道了。因此,twitter不是将整个文件作为JSON发送,相反ead发送捆绑在一起的多个JSON对象。