Hi,
I want to access the object in []
JSON literal as an array using FOR...IN
. But iterating through FOR...IN
gives the object x
undefined
. Please see the code below.
var myJSONObject = [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
];
for (var x in myJSONObject) {
alert(x['method']);
}
You may test the code online here @ JSBin
Regards,
Munim