A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://api.jquery.com/jQuery.parseJSON/ below:

jQuery.parseJSON() | jQuery API Documentation

jQuery.parseJSON( json )Returns: String or Number or Object or Array or Booleanversion deprecated: 3.0, removed: 4.0

Description: Takes a well-formed JSON string and returns the resulting JavaScript value.

As of jQuery 3.0, $.parseJSON is deprecated. To parse JSON strings use the native JSON.parse method instead.

Passing in a malformed JSON string results in a JavaScript exception being thrown. For example, the following are all invalid JSON strings:

The JSON standard does not permit "control characters" such as a tab or newline. An example like $.parseJSON( '{ "testing":"1\t2\n3" }' ) will throw an error in most implementations because the JavaScript parser converts the string's tab and newline escapes into literal tab and newline; doubling the backslashes like "1\\t2\\n3" yields expected results. This problem is often seen when injecting JSON into a JavaScript file from a server-side language such as PHP.

Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string. For details on the JSON format, see https://json.org/.

Prior to jQuery 1.9, $.parseJSON returned null instead of throwing an error if it was passed an empty string, null, or undefined, even though those are not valid JSON.

Example:

Parse a JSON string.

1

2

var obj = jQuery.parseJSON( '{ "name": "John" }' );

alert( obj.name === "John" );


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4