As Luca pointed out, add an extra line [] to your line and use the following code:
var myObject = eval('(' + myJSONtext + ')');
to check it, you can use the snippet below.
var s =" [{'id':1,'name':'Test1'},{'id':2,'name':'Test2'}]"; var myObject = eval('(' + s + ')'); for (i in myObject) { alert(myObject[i]["name"]); }
hope this helps.
AnarchistGeek Dec 07 '10 at 10:35
source share