Reputation: 2295
Hi I have a ajax request which returns this
[[{"totalloginhours":"11.17"}],[{"totalagents":"2"}],[{"totalapplications":"2"}]]
How do I access this string in jQuery? I don't need to loop.
I tried using $.parseJSON
to parse that string
var myObj2 = $.parseJSON(result2);
which returns
Upvotes: 0
Views: 28
Reputation: 2295
Foun a way to do this by
var string = '[[{"totalloginhours":"11.17"}],[{"totalagents":"2"}],[{"totalapplications":"2"}]]';
var myObj2 = $.parseJSON(string);
var obj_totalloginhours = myObj2[0];
var obj_totalagents = myObj2[1];
var obj_totalapplications= myObj2[2];
console.log(string);
console.log(obj_totalloginhours[0].totalloginhours);
console.log(obj_totalagents[0].totalagents);
console.log(obj_totalapplications[0].totalapplications);
JS Fiddle : https://jsfiddle.net/zu0x49ye/
Upvotes: 1