-1

我有与此类似的 JSON。我希望从此列表中提取名称、他的 id 和产品标题等值。但我无法弄清楚。我也在尝试“评估”。

{
    "data": [{
        "id": "3092773937557",
        "from": {
            "id": "1810306393",
            "name": "Prashant Singh"
        },
        "start_time": "2012-07-21T09:12:53+0000",
        "end_time": "2012-07-21T09:12:53+0000",
        "publish_time": "2012-07-21T09:12:53+0000",
        "application": {
            "id": "132692593533721",
            "name": "Compare Hatke"
        },
        "data": {
            "productname": "Apple iPod Nano",
            "price": 399,
            "product": {
                "id": "10151004296768984",
                "url": "http:\/\/compare.buyhatke.com\/products\/Apple-iPod-Nano",
                "type": "comparehatke:product",
                "title": "Apple iPod Nano"
            }
        },
        "likes": {
            "count": 0
        },
        "comments": {
            "count": 0
        },
        "no_feed_story": false
    }, {
        "id": "3092770217464",
        "from": {
            "id": "1810306393",
            "name": "Prashant Singh"
        },
        "start_time": "2012-07-21T09:08:53+0000",
        "end_time": "2012-07-21T09:08:53+0000",
        "publish_time": "2012-07-21T09:08:53+0000",
        "application": {
            "id": "132692593533721",
            "name": "Compare Hatke"
        },
        "data": {
            "productname": "Apple iPod Nano",
            "price": 399,
            "product": {
                "id": "10151004296768984",
                "url": "http:\/\/compare.buyhatke.com\/products\/Apple-iPod-Nano",
                "type": "comparehatke:product",
                "title": "Apple iPod Nano"
            }
        },
        "likes": {
            "count": 0
        },
        "comments": {
            "count": 0
        },
        "no_feed_story": false
    }],
    "paging": {
        "next": "https:\/\/graph.facebook.com\/me\/comparehatke:compare\/?access_token=AAAB4rubm4xkBAHRhdjVgx7JxIIvUxImIm31AMxgnqEAOQsAsgZAJjBYUfvzKc8XgxDBg3AzKN1S6QU2dnmtgj7TPcoCiih1RzrL3pLpuZAgGt8eKpq&limit=2&method=get&pretty=0&offset=2"
    }
}
4

2 回答 2

0
<html>
   <script style="text/javscript">
    var myObject = { "data": [{
        "id": "3092741696751",
        "from": {
        "id": "1810306393",
        "name": "Prashant Singh"
    },
     "start_time": "2012-07-21T08:40:38+0000",
     "end_time": "2012-07-21T08:40:38+0000",
     "publish_time": "2012-07-21T08:40:38+0000",
     "application": {
     "id": "132692593533721",
     "name": "Compare Hatke"
     },
     "data1": {
         "productname": "Apple iPod Nano",
         "price": 399,
         "product": {
         "id": "10151004296768984",
         "url": "http:\/\/compare.buyhatke.com\/products\/Apple-iPod-Nano",
         "type": "comparehatke:product",
         "title": "Apple iPod Nano"
      }
      },
      "likes": {
      "count": 0
      },
      "comments": {
      "count": 0
      },
      "no_feed_story": false
      } ]};
   alert(myObject.data[0].id);
   </script>
 </html>
于 2012-07-21T09:02:53.857 回答
0
data = JSON.parse(yourJSONString);

如果失败,您的 JSON 中可能有错误。您可以使用http://jsonlint.com/查找并解决问题。在上面的粘贴中,您缺少收盘价]}

于 2012-07-21T08:52:24.997 回答