Duplicate question How to list the properties of a JavaScript object
In modern browsers (IE9+, FF4+, Chrome5+, Opera12+, Safari5+) you can use the built in Object.keys method:
var obj = {
module1 : {type :'int' , value : 100 },
module2 : {type :'str' , value : 'bio' },
module3 : {type :'boolean' , value : 'true' }
}
var keys = Object.keys(obj);
The above has a full polyfill but a simplified version is:
var getKeys = function(myobj){
var keys = [];
for(var key in myobj){
keys.push(key);
}
return keys;
}
Alternatively replace var getKeys with Object.prototype.keys to allow you to call .keys() on any object. Extending the prototype has some side effects and I wouldn't recommend doing it.