1

How do I access the returned JSON Data? e.g the name array? to work

JSON...

{"COLUMNS":["NAME"],"DATA":[["Item 1"],["Item 2"]]} 

The data.NAME[1] doesn't seem to have any data in it..

 $.getJSON('url/json.php',
     function(data){
    $('#debug').html('data:' + data.NAME[1]);
            });
        });

3 Answers 3

2

Parsing your JSON string

{"COLUMNS":["NAME"],"DATA":[["Item 1"],["Item 2"]]} 

will return a javascript object like:

var data = {
    COLUMNS: ["NAME"],
    DATA: [["Item 1"], ["Item 2"]]   
}

so there is no identifier for data.NAME[1].

You may access data.COLUMNS[0] returning "NAME" or data.DATA[0][0] returning "Item 1".

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

1 Comment

+1 nice answer. You probably meant data.DATA[0][0] there. Weird JSON structure.
1

Not sure what you're trying to access.
data.COLUMNS[0] should get you "NAME".
data.DATA[0] should get you the ["Item 1"] array.

Comments

0

If you are using aspx make sure that you check data.d not data. (this was a recent change?)

1 Comment

its from coldfusion actually, SeralizeJSON function...oddness

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.