lorless
lorless

Reputation: 4478

Creating a better JSON format

I am returning a query object from Coldfusion as a JSON string which I then parse into JSON in Javascript. It has a bit of a strange format when I finally log it though.

I am faced with two problems. First, I do not know how to access the lowest element (i.e Arthur Weasley) as I cannot use a number in my selector (response.DATA[0].0 doesn't work because the lowest field name is a number). Second, is there any way to assign the values in the columns section to the fields that are numbered 1, 2 and 3?

What I'm really asking is how do I select my lowest level of data? If that can't be done because of the numbers for field names, how do I change the names to something more fitting?

My data logged:

enter image description here

Upvotes: 2

Views: 596

Answers (1)

DusteD
DusteD

Reputation: 1410

First entry of first entry of DATA = response.DATA[0][0]

So

name = reponse.DATA[0][0];
trainsThing = response.DATA[0][1];

Upvotes: 4

Related Questions