jQuery.parseJSON(json) (alias $.parseJSON) takes a well-formed JSON string and returns the matching JavaScript value (added in jQuery 1.4.1). When the browser has native JSON.parse, jQuery uses it under the hood.
Syntax
Start with these common calls. Keep them short and readable.
Unquoted key.{test: 1} is JavaScript object syntax, not JSON.
Single quotes. JSON requires double quotes for strings and keys.
Leading dot..1 is invalid — use 0.1.
Frequently Asked Questions
jQuery.parseJSON(json) takes a well-formed JSON string and returns the matching JavaScript value — an object, array, string, number, boolean, or null. It was the jQuery helper for parsing JSON text before dataType: "json" and native JSON.parse were universal.
The jQuery API demo is: var obj = jQuery.parseJSON('{ "name": "John" }'); then check obj.name === "John". It parses a small JSON object and reads a property.
Both parse valid JSON into JavaScript values. When the browser provides JSON.parse, jQuery uses it internally. Prefer native JSON.parse in all new code — $.parseJSON was deprecated in jQuery 3.0 and removed in jQuery 4.0.
$.parseJSON throws a JavaScript exception (same as JSON.parse). Invalid examples include unquoted keys, single quotes, undefined, NaN, and numbers like .1 without a leading zero. Wrap external data in try/catch.
No. Use JSON.parse() for new work. Keep $.parseJSON only while maintaining jQuery 1.x–3.x legacy code. Migrate before upgrading to jQuery 4.
JSON forbids literal control characters inside strings. If a server injects a JS string with real tab/newline characters, parsing fails. Double the backslashes ("1\\t2\\n3") so the JSON text keeps the escape sequences.
Prior to jQuery 1.9, $.parseJSON returned null for an empty string, null, or undefined instead of throwing — even though those are not valid JSON. Modern JSON.parse("") throws a SyntaxError.