Hello Guys,
I will explain that how to extract values from JSONArray String in Javascript.
For example we have this jsonarray string below:
var jsonarraystr ='[{
"city": "Jaipur",
"state": "Rajasthan",
},
{
"city": "Ahmedabad",
"state": "Gujrat",
},
{
"city": "Delhi",
"state": "New Delhi",
}]';
jsonarraystr is javascript variable which have JsonArray String.
Now, we extract values from jsonarraystr variable using below javascript code :
var jsonarray = JSON.parse(jsonarraystr);
for(var i=0;i< jsonarray.length;i++)
{
var city = jsonarray[i].city;
var state = jsonarray[i].state;
}
Thanks
0 Comment(s)