parse facebook json javascript

parse facebook json javascript

本文关键字:javascript json facebook parse      更新时间:2023-09-26

我正在使用javascript api来获取Facebook评论。

我得到以下 JSON 结果,但我如何解析它们以在我的页面上使用?

  {
      "id": "1234567891_2823098717038_3160191",
      "from": {
        "name": "User",
        "id": "1234567891"
      },
      "message": "comment only...",
      "can_remove": true,
      "created_time": "2012-05-05T07:43:11+0000"
    },
    {
      "id": "1234567891_2823098717038_3160281",
      "from": {
        "name": "User",
        "id": "1234567891"
      },
      "message": "just another comment...",
      "can_remove": true,
      "created_time": "2012-05-05T08:14:17+0000"
    },
    {
      "id": "1234567891_2823098717038_3160336",
      "from": {
        "name": "user2",
        "id": "56265654845454"
      },
      "message": "congratz dear :)",
      "can_remove": true,
      "created_time": "2012-05-05T08:29:05+0000"
    }
  ],
  "paging": {
    "next": "http://link.dddd"
  }
}

我怎样才能循环浏览并显示内容?

jQuery解决方案是可以接受的。

谢谢。

使用 JQuery.parseJSON : http://api.jquery.com/jQuery.parseJSON/

> assoc_data = jQuery.param(response);//where response is your json

$.ajax({ 类型:"开机自检", 网址: "submit_fb_data.php", 数据:assoc_data, 成功: 函数(数据) {

//etc

}

});

  • 确保使用>=1.4 jQuery 版本