Object.withUpperCaseKeys = function upperCaseKeys(o) {
var r = {};
for (var p in o)
r[p.toUpperCase()] = o[p];
return r;
}
Use this method to create a new object with different keys:
JSONObj.people = Object.withUpperCaseKeys(JSONObj.people);
If you want to change the object (change the instance), use
Object.upperCaseKeys = function upperCaseKeys(o) {
for (var p in o)
if (p.toUpperCase() != p) {
p[p.toUpperCase()] = o[p];
delete o[p];
}
return o;
}
Object.upperCaseKeys(JSONObj.people);
Bergi source
share