tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

jQuery.parseJSON( json )

jQuery.parseJSON( json )

Returns: Object
Description: Takes a well-formed JSON string and returns the resulting JavaScript object.

Arguments

jQuery.parseJSON( json )

version added: 1.4.1
json
JSON string
The JSON string to parse.

Passing in a malformed JSON string will 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/.

Example

Parse a JSON string.
var obj = jQuery.parseJSON('{"name":"John"}');
alert( obj.name === "John" );
Was this information helpful?
   

Comments