How to parse these JSon array am getting from json_encode(arr), the output is:
[{"id":"44","data":"[[10],[27],[13]]","_types":"ff"}, {"id":"44","data":"[[140],[327],[213]]","_types":"44f"}]
I need to iterate this using java script and fetch each values. Am getting an error, Unexpected token.
You are getting a string, you simply need to do JSON.parse
var str = '[{"id":"44","data":"[[10],[27],[13]]","_types":"ff"}, {"id":"44","data":"[[140],[327],[213]]","_types":"44f"}]';
var obj = JSON.parse( str );
alert( obj[0].id );
You are getting array of java script object,i think you don't need to parse this.Just iterate this and fetch the result like below.
var q = [{"id":"44","data":"[[10],[27],[13]]","_types":"ff"}, {"id":"44","data":"[[140],[327],[213]]","_types":"44f"}];
q.forEach(function(i){console.log(i.id)});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With