简体   繁体   中英

How to use a stringify JSON data from Yelp API

I am trying to figure out how to use the data in Yelp API v2 . How do you read the data given by yelp after you json.stringify it. This is what I did,

var output = JSON.stringify(data);
alert(output[0].id) // This comes out to be undefined.

How do you read the json data from yelp api?

data should already be an object. alert(data[0].id) . If you're grabbing it from $.ajax , which I assume, it will return an object.

If data is a string, then you want:

var output = JSON.parse(data);
alert(output[0].id)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM