PDA

View Full Version : How to get value inside another jsonObject



sunder
15 Sep 2010, 8:44 PM
I want fatch outbound value which is inside another jsonobject. that is in example given below "outbound".
{"totalCount":1,"price":[{"price":"119.07","adult":1,"outbound":[{"locidfrom":"LAX","dateofdept":"190910"}]}]}

so anyone can tell me how can i get outbound value("locidfrom","dateofdept") in my js file.
How can i map this outbound object to show the result.

aconran
23 Sep 2010, 5:39 PM
Assuming that this string of JSON is in a variable called jsonString...



var obj = Ext.decode(jsonString);
var firstOut = obj.price[0].outbound[0];
console.log(firstOut.locidfrom);
console.log(firstOut.dateofdept);