How to Decode JSON Data in jQuery

Types of JSON
JSON depend upon two basic structures:


"tuotorial": {
"name": "dhamika Ronamika and the Goblet of Fire",
"owner": "J. K. Savaliya",
"year": 2022,
"genre": "Fantasy Fiction",
"bestseller": true

How to decode and encode JSON Data in JavaScript?

json decode in jquery
parse json jquery

var obj = JSON.parse('{ "name":"Virat", "age":30, "city":"India"}');

json_decode jquery

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

javascript parse json

var jsonPerson = '{"first_name":"Vamika", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object

javascript parse json

const json = '{ "websites": "pakainfo", "ranks": 10 }';
const obj = JSON.parse(json);
console.log(obj.websites, obj.ranks);

json_decode javascript


Parsing JSON Data in JavaScript

{"name": "Virat", "age": 22, "country": "United Kigdom"}

using the JSON.parse( ) method

// Store JSON data in a JS variable
var json = '{"name": "Virat", "age": 22, "country": "United Kigdom"}';

// Converting JSON-encoded string to JS object
var obj = JSON.parse(json);

// Accessing individual value from JS object
alert(; // Outputs: Virat
alert(obj.age); // Outputs: 22
alert(; // Outputs: United Kigdom

Parsing Nested JSON Data in JavaScript

nested JSON objects and arrays.

var json = `{
"tuotorial": {
"name": "Dhamika Ronamika and the Goblet of Fire",
"owner": "J. K. Savaliya",
"year": 2022,
"slogen": ["Dhamika Ronamika", "Pakila Manchriyam", "Siyamni Dipalishiji"],
"genre": "Fantasy Fiction",
"earning": {
"paperback": "$48.40", "hardcover": "$55.32", "kindle": "$4.11"

var obj = JSON.parse(json);

function printValues(obj) {
for(var k in obj) {
if(obj[k] instanceof Object) {
} else {
document.write(obj[k] + "<br>");



document.write(obj["tuotorial"]["owner"] + "<br>"); // Displays: J. K. Savaliya
document.write(obj["tuotorial"]["slogen"][0] + "<br>"); // Displays: Dhamika Ronamika
document.write(obj["tuotorial"]["earning"]["hardcover"]); // Displays: $55.32

Encoding Data as JSON in JavaScript

Stringify a JavaScript Object

// Sample JS object
var obj = {"name": "Virat", "age": 22, "country": "United Kigdom"};

// Converting JS object to JSON string
var json = JSON.stringify(obj);


{"name":"Virat","age":22,"country":"United Kigdom"}

Stringify a JavaScript Array

// Sample JS array
var arr = ["pakainfo", "w3diy", "Infinityknow", "ng4free", "live24u"];

// Converting JS array to JSON string
var json = JSON.stringify(arr);



I hope you get an idea about json decode in jquery.


How to Decode JSON Data in jQuery
1.10 GEEK