0

I have below JSON Data which constitutes inner array How to read data from 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 
}
]
}

I am accessing URL which returns me data in above JSON format I want get values from that Array listEdition and An array listInsertion in side that Edition Array and same from that listPackage array which has that full listEdition array.

5
  • 1
    This is not valid JSON; object member names must be JSON strings Commented Jun 17, 2013 at 14:05
  • So, what have you tried so far? Commented Jun 17, 2013 at 15:17
  • I've edited the answer with a correct json, but the one befor was not valid. If you were using that one you have to fix that! Commented Jun 17, 2013 at 16:01
  • can anybody guide me how to get all those values from above JSON Commented Jun 18, 2013 at 6:28
  • can anybody help me with source code Commented Jun 18, 2013 at 7:49

1 Answer 1

1

use the following code:

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)
        }

i think it will meet your demand.you can see the example:http://jsfiddle.net/rayhan/x2H5W/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.