$.getJSON("hello.txt", function(json) {
console.log(json);
alert(json.rgInventory[2].id);
});
使用下面的代码我试图从hello.txt文件中解析JSON信息并显示它。正如你所看到的,代码下的图片能够正确识别JSON信息,但是当试图从第三个元素打印出它的rgInventory对象时,它说未定义。JSON解析问题undefined
有这一个与信息内许多对象,并都有一个ID。我正在使用的JSON数据可以在这里找到:http://steamcommunity.com/id/flaangvik/inventory/json/730/2
请张贴在请求返回的JSON。 –
尝试console.log(json.rgInventory); –
这是json - > http://steamcommunity.com/id/flaangvik/inventory/json/730/2 –