Reading Json in Javascript

To read JSON in JavaScript what all we need is eval operator

var t = "{ user : [{name : 'Lokesh' , Age : '26' },{name : 'Vishal' , Age : '28' }] }"
var f = eval(t)
alert(f[1].name);

the above code will pop up an alert box with “Vishal”.

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*