[英]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 . 我试图弄清楚如何在Yelp API v2中使用数据。 How do you read the data given by yelp after you json.stringify it. json.stringify后,如何读取yelp提供的数据。 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? 您如何从yelp api读取json数据?
data
should already be an object. data
应该已经是一个对象。 alert(data[0].id)
. alert(data[0].id)
。 If you're grabbing it from $.ajax
, which I assume, it will return an object. 如果您从$.ajax
(我假设是它)中获取它,它将返回一个对象。
If data
is a string, then you want: 如果data
是字符串,那么您需要:
var output = JSON.parse(data);
alert(output[0].id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.