Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
对JSON格式的详细操作_Json - Fatal编程技术网

对JSON格式的详细操作

对JSON格式的详细操作,json,Json,需要JSON格式的操作 我从twitterstream流式传输了这个JSON文件,但在检查JSONLint时,我发现以下错误 Error: Parse error on line 11: ...1554180840158" }} { "delete": { "st ---------------------^ Expecting 'EOF', '}', ',', ']', got '{' JSON代码:- { "delete": { "status":

需要JSON格式的操作

我从twitterstream流式传输了这个JSON文件,但在检查JSONLint时,我发现以下错误

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"
    }
}]

JSONLT抱怨它不是一个有效的对象。实际上,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"
    }
}]

你发布的不是JSON,而是两个用空格分隔的JSON对象。你发布的不是JSON,而是两个用空格分隔的JSON对象。谢谢Jamie,我现在知道了。因此,twitter不是将整个文件作为JSON发送,而是将多个JSON对象捆绑在一起发送。谢谢Jamie,我现在知道了。因此,twitter不是将整个文件作为JSON发送,相反ead发送捆绑在一起的多个JSON对象。