I need to go through the js object and replace all the dots with underscores in these object keys.
for instance
{a.a:"test"}
to
{a_a:"test"}
This is my code.
Object.getOwnPropertyNames(match).forEach(function(val, idx, array) {
if(val.indexOf(".") != -1){
val.replace(/\./g,'_');
}
});
Thank you, but my problem in the object is not as simple as this
{
"a.a":{
"nee.cc":"sdkfhkj"
},
"b.b": "anotherProp"
}
OlegL source
share