You are trying to treat Object as Array , and Object not Array , it is Object .
Whenever you see {} in JSON, it means that "what is contained in these sacred brackets is a dynamic object." When you see [] , it means: βHere! I am an Arrayβ (there are notable exceptions to this: jQuery does some special work to make itself look like an array).
So, to iterate through Object , you will want to use for... in .
// eval BAD unless you know your input has been sanitized!. var myObj = JSON.parse('{"notempty":true}'); // personally, I use it in for... in loops. It clarifies that this is a string // you may want to use hasOwnProperty here as sometimes other "keys" are inserted for( var it in myObj ) console.log( "myObj["+it+"] = " + myObj[it] );
source share