从json输出检索数据时出现问题
说到json,我是个笨蛋。我用得越多,我就开始喜欢它了。我有一个像这样的输出从json输出检索数据时出现问题,json,facebook,fbjs,Json,Facebook,Fbjs,说到json,我是个笨蛋。我用得越多,我就开始喜欢它了。我有一个像这样的输出 [ { "product": { "id": "6", "category": "Books", "created": "2010-04-13 15:15:18", }, "availability": [ { "country": "U
[
{
"product": {
"id": "6",
"category": "Books",
"created": "2010-04-13 15:15:18",
},
"availability": [
{
"country": "United Kingdom",
"price": "$13.99",
},
{
"country": "Germany",
"price": "$13.99",
}
]
}
]
实际上我只列出了一种产品,但output列出了许多产品。我想循环浏览这个json输出,并使用fbjs获取所有产品的类别、可用的国家和价格
谢谢你的帮助
谢谢 如果您的JSON是这样的
var products = [
{
"product": {
"id": "6",
"category": "Books",
"created": "2010-04-13 15:15:18",
},
"availability": [
{
"country": "United Kingdom",
"price": "$13.99",
},
{
"country": "Germany",
"price": "$13.99",
}
]
},
{
"product": {
"id": "7",
"category": "Books",
"created": "2010-04-13 15:15:18",
},
"availability": [
{
"country": "United Kingdom",
"price": "$13.99",
},
{
"country": "Germany",
"price": "$13.99",
}
]
}
]
您可以迭代:
for(var index = 0; index < products.length; index++) {
alert(products[index].product.category);
}
for(var索引=0;索引
你能告诉我们你在解析的JSON中循环使用的代码吗?@TheyCallMemory我想我会使用$。每个方法,但我不知道fbjs中的相同方法。