GregT

26 Nov 2009, 6:26 AM

Given this JSON:

{"result":

{"f":

[

{"x":"y"}

],

"g":

{

"j":"k"}

}

}

}

The point is, 'f' contains a set of 'records', whereas 'g' contains a single value.

It is no problem to parse 'f.x' out of here using a JsonReader, but what is the correct way to obtain the value of 'g.j'?

This seems to work:

eval(result).g.j;

... but as I understand it, 'eval' is to be avoided. Is this a case where it is unavoidable, or is there some other way to do this? I tried experimenting with different configurations of JsonReader as well as Ext.util.JSON.decode.

Any advice appreciated.

{"result":

{"f":

[

{"x":"y"}

],

"g":

{

"j":"k"}

}

}

}

The point is, 'f' contains a set of 'records', whereas 'g' contains a single value.

It is no problem to parse 'f.x' out of here using a JsonReader, but what is the correct way to obtain the value of 'g.j'?

This seems to work:

eval(result).g.j;

... but as I understand it, 'eval' is to be avoided. Is this a case where it is unavoidable, or is there some other way to do this? I tried experimenting with different configurations of JsonReader as well as Ext.util.JSON.decode.

Any advice appreciated.