Wednesday, January 11, 2012

JSON data is not parsed?


I followed the advice here on how to use JSON.



After using




$resultAml = json_encode($resultArray);



in PHP I get this at the client:




[{"id":"1","0":"1","title":"Facebook","1":"Facebook","url":"http://facebook.com","2":"http://facebook.com","domain":"facebook.com","3":"facebook.com","tag":"","4":""},{"id":"1","0":"1","title":"Ideeli","1":"Ideeli","url":"http://www.ideeli.com","2":"http://www.ideeli.com","domain":"ideeli.com","3":"ideeli.com","tag":"web","4":"web"},{"id":"1","0":"1","title":"Kikin","1":"Kikin","url":"http://www.kikin.com","2":"http://www.kikin.com","domain":"kikin.com","3":"kikin.com","tag":"web","4":"web"},{"id":"1","0":"1","title":"Lot18","1":"Lot18","url":"http://www.lot18.com","2":"http://www.lot18.com","domain":"lot18.com","3":"lot18.com","tag":"web","4":"web"},{"id":"1","0":"1","title":"Quora","1":"Quora","url":"http://quora.com","2":"http://quora.com","domain":"quora.com","3":"quora.com","tag":"","4":""},{"id":"1","0":"1","title":"Twitter","1":"Twitter","url":"http://twitter.com","2":"http://twitter.com","domain":"twitter.com","3":"twitter.com","tag":"","4":""}]



That looks like valid JSON according to json.org



Howwever,



When I parse it on the client side using




JSON.parse



I get this result:




[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]



Looks like one [object Object] for each entry in the table.



What is object Object?



Where did I go wrong here? Or if not how do I get to the data in the result?

No comments:

Post a Comment