0

我有以下构成内部数组的JSON数据如何从内部数组读取数据

{
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 数组中获取相同的值。

4

1 回答 1

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/

于 2013-06-17T14:44:06.063 回答