Javatpoint Logo
Javatpoint Logo

jQuery parseJSON() method

The jQuery parseJSON() method takes a JSON string and returns a JavaScript object. The specified JSON string must follow the strict JSON format. Passing an incorrect string will cause a JS exception.

Some of the examples of malformed JSON strings that can cause an exception on passing are given as follows -

As similar to the above strings, multiple other malformed strings will cause an exception. The JSON standard also does not allow the appearance of control characters (such as tab or newline character) in the string.

Before jQuery version 1.9, if we pass an empty string, null, or undefined, the parseJSON() method returned null instead of throwing an error.

Syntax

This method accepts a single parameter, which is defined as follows -

json: It is the valid JSON string to parse.

Now, let's understand the working of this method using an illustration.

Example

Here, we are passing a well-formed JSON string to the parseJSON() method. We have to click the given button to get the output.

Test it Now

Output

After the execution of the above code, the output will be -

jQuery parseJSON() method

After clicking the given button, the output will be -

jQuery parseJSON() method





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA