Return to Snippet

Revision: 40882
at February 9, 2011 10:28 by iroybot

Initial Code
var obj = JSON.parse('{"someKey":10,"otherKey":20}') ;

for(var prop in obj) {
    if(obj.hasOwnProperty(prop))[prop]); // value; // key name

Initial URL

Initial Description
I wanted to pass a form submission (array) as a JSON object to another function.
Some form field were created with JS, to identify them their names have been concatenated with unique IDs, etc.
In order to access values of that JSON obj I needed to find out the key names in order to get data out of it.

Initial Title
getting an objects key values

Initial Tags
js, object, array, json

Initial Language