Skip to content Skip to sidebar Skip to footer

Dealing With Json Result

I'm having trouble reading the JSON data from a venues search. Here is my code: xmlhttpRC = new XMLHttpRequest(); url = 'https://api.foursquare.com/v2/venues/explore?ll='+pointStrr

Solution 1:

You need to parse JSON. Modern browsers have JSON.parse built in, older versions of IE etc. do not - you can theoretically use eval(response) but it creates a security hole.

There is a library to parse it if you cannot depend on users having modern browsers.

Solution 2:

var decodedResp = JSON.parse(recRes);
if (decodedResp.meta.code === ...) 

JSON-object is just a representation of an JS-object, see; it should be parsed first.

Post a Comment for "Dealing With Json Result"