This parseJSON() method in jQuery takes a well-formed JSON string and returns the resulting JavaScript value.
Syntax:
jQuery.parseJSON( json )
Parameters: The parseXML() method accepts only one parameter that is mentioned above and described below:
- json: This parameter is the well-formed JSON string to be parsed.
Return Value:
- It returns the following:
- String
- Number
- Object
- Array
- Boolean
Example 1: In this example, we are using the above-explained approach.
html
<!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
< title >JQuery | parseJSON() method</ title >
< script src =
</ script >
< style >
#a {
color: blue;
}
#b {
color: red;
}
h1 {
color: green;
}
body {
text-align: center;
}
</ style >
</ head >
< body >
< h1 >
GeeksForGeeks
</ h1 >
< h3 >JQuery | parseJSON() method</ h3 >
< b id = "a" ></ b >
< script >
let txt = '{"name":"John", "age":30, "city":"New York"}'
let obj = jQuery.parseJSON(txt);
document.getElementById("a").innerHTML =
"Object Name : " + obj.name +
"< br > Object Age : " + obj.age;
</ script >
</ body >
</ html >
|
Output:

Example 2: In this example, we are using the above-explained approach.
html
<!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
< title >JQuery | parseJSON() method</ title >
< script src =
</ script >
</ head >
< body style = "text-align:center;" >
< h1 style = "color: green" >
GeeksForGeeks
</ h1 >
< h3 >JQuery | parseJSON() method</ h3 >
< button onclick = "gfg()" >
Click
</ button >
< script >
function gfg() {
let txt = '{"name":"Shubham Singh", "age":21, "Cars":"ABC" }'
let obj = jQuery.parseJSON(txt);
alert(obj.name === "ABC");
}
</ script >
</ body >
</ html >
|
Output:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!