jQuery.parseJSON() **DEPRECATED in Version 3.0**
JQ Home <<
Utilities <<
jQuery.parseJSON()
Object creation from parsed JSON data.
Description
The jQuery.parseJSON() jQuery General utility method, returns a JavaScript Object object created from the specified well-formed JSON string.
Shorthand version $.parseJSON()
- Passing a malformed JSON string to the
jQuery.parseJSON()jQuery General utility method can result in an exception being thrown by the browser. - Passing
null,or an empty string to theundefinedjQuery.parseJSON()jQuery General utility method results innullbeing returned from the method. - If the browser being used provides a native implementation of
JSON.parse, jQuery will use it to parse the string.
This method was deprecated in jQuery 3.0 and has no effect in browsers that support the requestAnimationFrame method.
Syntax
| Signature | Description |
|---|---|
jQuery.parseJSON( json ) | Return The JavaScript Object object created from the specified well-formed JSON string. |
Parameters
| Parameter | Description | Type |
|---|---|---|
json | The JSON string to parse. | String |
Return
An Object object.
jQuery.parseJSON( json ) Example
Utilities << Top
Return a JavaScript Object object created from the specified well-formed JSON string.
In the example below when we press the button we parse some well formed JSON to a variable. Then we output a message displaying the properties of the Object object we created.
$(function(){
$('#btn8').one('click', function(){
var obj = jQuery.parseJSON('{"str1":"A stitch in time ","str2":"Saves nine"}');
$('#div8').append(obj.str1 + obj.str2);
});
});
div8. Some initial text.
Related Tutorials
jQuery Intermediate Tutorials - Lesson 9 - jQuery General Utilities
