在浏览器中查看时,Facebook如何格式化其API的JSON输出?

时间:2014-03-27 10:34:29

标签: json facebook api

通过浏览器访问Facebook图表时,例如:

http://graph.facebook.com/1633633315

我得到了一些格式良好的JSON:

{
   "id": "1633633315",
   "name": "Karat Noppakoon",
   "first_name": "Karat",
   "last_name": "Noppakoon",
   "gender": "female",
   "locale": "en_US",
   "username": "Karat.Noppakoon"
}

在访问许多其他API时,例如Flickr,输出将不会格式化:

{"photos":{"page":1,"pages":543882,"perpage":10,"total":"5438811","photo":[{"id":"3346088899","owner":"35260559@N03","secret":"e2a2e20a0a","server":"3366","farm":4,"title":"web development","ispublic":1,"isfriend":0,"isfamily":0,"url_o":"https:\/\/farm4.staticflickr.com\/3366\/3346088899_b6fcda66f5_o.jpg","height_o":"309","width_o":"386","url_m":"https:\/\/farm4.staticflickr.com\/3366\/3346088899_e2a2e20a0a.jpg","height_m":"309","width_m":"386"}

1 个答案:

答案 0 :(得分:3)

Facebook的JSON中隐藏了\ r \ n(return, newline)个字符。它毫无意义,占用略微更多空间,因为它只对可读性有用。其他API不会这样做。它对如何解析字符串没有区别。

编辑:请看Notepad ++中的截图设置为显示隐藏/不可见的字符。

enter image description here