我在使用json.parse访问json中的值时遇到了问题。这是我的JSON:
[
{
"store":[
{
"name":"Grand Theft Auto V"
},
{
"skuid":"UP1004-CUSA00419_00-GTAVDIGITALDOWNL-U001"
},
{
"releasedate":"2014-11-18T00:00:00Z"
} //...我正在尝试从store数组中获取name。
var cif = JSON.parse(response);
// Tried the following:
alert(cif["store"][0].name);
alert(cif.store[0].name);
alert(cif[0].store.name);
alert(cif["store"].name);
if(cif.store[0].name) $("#cif-title").html(cif.store[0].name);如何访问此值?
发布于 2018-06-01 03:37:58
这应该是可行的。
alert(cif[0]["store"][0]["name"]);或
alert(cif[0].store[0].name);发布于 2018-06-01 03:38:16
试试console.log(cif[0].store[0].name)
https://stackoverflow.com/questions/50631502
复制相似问题