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