jQuery.parseJSON( json )



jQuery.parseJSON( json )


Passing in a malformed JSON string may result in an exception being thrown. For example, the following are all malformed JSON strings:
{test: 1} (test does not have double quotes around it).
{'test': 1} ('test' is using single quotes instead of double quotes).


Additionally if you pass in nothing, an empty string, null, or undefined, 'null' will be returned from parseJSON. Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string. For details on the JSON format, see http://json.org/.




翻译:
jQuery.parseJSON( json )
传入格式有误的 JSON 字符串可能导致抛出异常。例如,下面这些 JSON 字符串格式都不对:
{test: 1} (test 没有使用双引号包裹).
{'test': 1} ('test' 用了单引号而不是双引号包裹).
另外,如果你什么都不传入,或者传入空字符串、null、undefined 等,parseJSON 都会返回 null 。如果浏览器原生实现了 JSON.parse, jQuery 则会使用它来解析字符串。更多关于JSON格式的细节请参考 http://json.org/ 







发布了51 篇原创文章 · 获赞 6 · 访问量 15万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章