Thursday, December 6, 2012

Deleting Property from JSON Object


Say I create an object thus:

var myJSONObject = {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"};

What is the best way to remove the property 'regex'? i.e. I would like to end up with myJSONObject such that:

myJSONObject =  {"ircEvent": "PRIVMSG", "method": "newURI"};


You can remove it

delete myJSONObject['regex']

or 

delete myJSONObject.regex


No comments: