Karthik
Karthik

Reputation: 1219

Split json data from json array in jquery

I'm getting a JsonArray like this, by using urlrequest method in jquery

Object {
code:"INR"
price:"14999"
status:"sucess"
qty:"5"
title:"Moto G Plus, 4th Gen (Black, 32 GB)"
}

Now i need to print, certain jsonarray values, using jquery like this

title - Moto G Plus, 4th Gen (Black, 32 GB)
price - 14999

Upvotes: 0

Views: 1980

Answers (2)

Computerlucaworld
Computerlucaworld

Reputation: 387

If you want to loop through the properties of the object you can use the keys method that returns the properties of the object and access the object propertywith the dot notation or the [] notation.

Upvotes: 0

Bunny Joel
Bunny Joel

Reputation: 171

If you want print each key and value in your json object use this method. json in the function should be you json object. Key and value is your id and value.

$.each(json, function(key,value){
            alert("output: "+key+" value "+value); 
            });

Upvotes: 2

Related Questions