【问题标题】:Whats wrong with my JSON Object [closed]我的 JSON 对象有什么问题[关闭]
【发布时间】:2014-06-26 09:37:57
【问题描述】:

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

{"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 包

【问题讨论】:

  • 人不是工具:jslint.com
  • 您应该使用 JSONLint 验证您的 JSON。它表明您缺少]。这个问题应该结束了。
  • 是的,我认为标记为“offtopic,因为它是一个简单的错字”会是一个更好的选择..
  • 报错的原因是你删除了... truncated ...],这行但是没有离开]

标签: python json


【解决方案1】:

您在底部缺少一个结束 ],这将起作用

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

【讨论】:

    【解决方案2】:

    results 参数缺少一个结束符 ]。

    使用this 验证您的 JSON 对象

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 2013-02-19
      • 1970-01-01
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 2016-07-07
      • 2013-02-11
      相关资源
      最近更新 更多