我的JSON对象有什么问题

2024-09-28 21:59:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下直接取自http://www.jquery4u.com/json/twitter-json-example/的json:

{"results":[

     {"text":"@twitterapi  http:\/\/tinyurl.com\/ctrefg",

     "to_user_id":396524,

     "to_user":"TwitterAPI",

     "from_user":"jkoum",

     "metadata":

     {

      "result_type":"popular",

      "recent_retweets": 109

 

     },

     "id":1478555574,  

     "from_user_id":1833773,

     "iso_language_code":"nl",

     "since_id":0,

     "max_id":1480307926,

     "refresh_url":"?since_id=1480307926&q=%40twitterapi",

     "results_per_page":15,

     "next_page":"?page=2&max_id=1480307926&q=%40twitterapi",

     "completed_in":0.031704,

     "page":1,

     "query":"%40twitterapi"}

}

python中出现以下错误:

ValueError: No JSON object could be decoded

我的json对象有什么问题?你知道吗

我使用python附带的标准json包


Tags: tofromcomidjsonhttpwwwpage
2条回答

你在底部缺少一个结束语],这样就行了

{
    "results": [
        {
            "text": "@twitterapi  http://tinyurl.com/ctrefg",
            "to_user_id": 396524,
            "to_user": "TwitterAPI",
            "from_user": "jkoum",
            "metadata": {
                "result_type": "popular",
                "recent_retweets": 109
            },
            "id": 1478555574,
            "from_user_id": 1833773,
            "iso_language_code": "nl",
            "since_id": 0,
            "max_id": 1480307926,
            "refresh_url": "?since_id=1480307926&q=%40twitterapi",
            "results_per_page": 15,
            "next_page": "?page=2&max_id=1480307926&q=%40twitterapi",
            "completed_in": 0.031704,
            "page": 1,
            "query": "%40twitterapi"
        }
    ]
}

results参数缺少一个[closing]。你知道吗

使用this验证JSON对象

相关问题 更多 >