PDA

View Full Version : [solved]how2 remove : property : "value" from json Object ?



democrie
4 Aug 2007, 5:32 AM
First of all Hello to everybody, this is my first one B)

having one elementary JSON object name Properties, made with Ext.decode() from an array for example, i can access to a precise Property or affect it by :

DaProperty = Properties[ Property ]
Properties[ Property ] = myNewPropertyValue

The question is quite simple : How can I retreive one property ?
and by the way, i may have not have seen any document about functions concerning access to a json object.

thx in advance

jay@moduscreate.com
4 Aug 2007, 5:41 AM
hope this helps.

example:


var jsonData1 = "{ attribute1 : 'value1', attribute2 : 'value2' }";

var jsonDataDecoded = Ext.util.JSON.decode(jsonData1);

alert(jsonDataDecoded.attribute1);
alert(jsonDataDecoded.attribute2);


var jsonData2 = "{ attribute1 : [ { attribute1_1 : 'value1'}, { attribute1_2 : 'value2'} ]}";
var jsonDataDecoded2 = Ext.util.JSON.decode(jsonData2);

alert(jsonDataDecoded2.attribute1[0].attribute1_1);

democrie
4 Aug 2007, 5:52 AM
i guess my explanations were not good...

given
var jsonData1 = "{ attribute1 : 'value1', attribute2 : 'value2' }";

i would like to remove the attribute1 and its value from jsonData1

thx

jack.slocum
4 Aug 2007, 12:54 PM
delete jsonData1.attribute1;

democrie
4 Aug 2007, 1:38 PM
it was that simple.