PDA

View Full Version : Get a JSON property on the controller



RodManMx
5 Jun 2012, 2:44 PM
Hi everybody,

I'm wondering if is it possible to fetch an specific property from a JSON, I mean, I've got the next json file



{
success : true,
flag : 2,
data : [ .... ]
}


And I want to get the flag propertie from the controller of the grid that loads this json file, is it possible to do?

Cheers!

scottmartin
5 Jun 2012, 4:28 PM
You just need to use access the data.fieldname property of your response



success: function(xhr) {
var response = Ext.decode(xhr.responseText);
if (response.success === true) {
var jsonData = Ext.util.JSON.decode(xhr.responseText);
// jsonData.data.flag;
}
},


Regards,
Scott.