• 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/