Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从json输出检索数据时出现问题_Json_Facebook_Fbjs - Fatal编程技术网

从json输出检索数据时出现问题

从json输出检索数据时出现问题,json,facebook,fbjs,Json,Facebook,Fbjs,说到json,我是个笨蛋。我用得越多,我就开始喜欢它了。我有一个像这样的输出 [ { "product": { "id": "6", "category": "Books", "created": "2010-04-13 15:15:18", }, "availability": [ { "country": "U

说到json,我是个笨蛋。我用得越多,我就开始喜欢它了。我有一个像这样的输出

[
    {
        "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中的相同方法。