我有以下JSON数据构成内部数组 如何从Inner Array中读取数据
{
TRANSACTION:[
{
listEditions: [
{
"adRoute":"B",
"listInsertion":[
{
"color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
}
],
listPackage:
[
{
listEditions: [
{
"adRoute":"B",
"listInsertion":[
{
"color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
},
{
"adRoute":"A",
"listInsertion":[
{ "color":0,"colorType":"All Colour","fromDate":"26/06/2013","height":25,"page":2,"pagePosition":2,"pagePositionType":"Regular Page","size":823,"sizeDimention":"32.9x25","toDate":"26/06/2013","width":32.9,"pubDate":""
}
]
}
]
}],
referenceID: E13F42EC5E38
}
]
}
我正在访问以上面的JSON格式返回数据的URL 我想从版本数组中获取该数组listEdition和数组listInsertion中的值 和那个具有完整listEdition数组的listPackage数组相同。
答案 0 :(得分:1)
使用以下代码:
for(var i = 0; i < listEditions.length; i++)
{
var arrayItem=item.listEditions[i].listInsertion;
//get colorType value
alert(arrayItem[0].colorType);
//get color value
alert(arrayItem[0].color)
}
我认为它会满足您的需求。您可以看到示例:http://jsfiddle.net/rayhan/x2H5W/