正在解析 JSON 对象以获取文件位置

parsing JSON object to get filelocation

我是 JSON 的新手。在这里,我面临如何从 JSON 对象获取文件位置的问题,我正在使用 javascript 来解析 json

{
"_embedded": {
    "binaries": [
        {
            "fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
            "username": "testuser3",
            "description": "The company required the 28-year-old's help on a matter the directors felt could affect the share price: its Wikipedia page. Short, uninteresting .",
            "createdAt": "2015-02-01T21:47:07.000+0000",
            "updatedAt": "2015-02-01T22:42:16.000+0000"
        },
        {
            "fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
            "username": "Sumanth",
            "description": "Sample",
            "createdAt": "2015-02-23T21:37:13.000+0000",
            "updatedAt": "2015-02-23T21:43:11.000+0000"
        },
        {
            "fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
            "username": "as",
            "description": "as",
            "createdAt": "2015-02-02T22:46:00.000+0000",
            "updatedAt": "2015-02-27T22:06:18.000+0000"
        }
    ]
}

}

我想从 JSON 对象读取所有文件位置。 谁能帮我。提前致谢

您尝试访问 fileLocation 的方式看起来是正确的:

data._embedded.binaries[1].fileLocation

在此之前,要解析您的数据,请使用:

parsed = JSON.parse(data);

这是 fiddle:http://jsfiddle.net/01aL5upc/ 请注意,我确实删除了 fiddle 中 28 岁的空格和撇号,以将其放入字符串而不是 ajax 请求中。