🔑 Recursively replace object keys
$ npm install --save recursive-key-replace
const recursiveKeyReplace = require('recursive-key-replace');
const obj = {
"cats.are.cool": true,
"dogs": {
"are.too": true
}
};
recursiveKeyReplace(obj, /\./g, '');
//=> {"catsarecool": true, "dogs": {"aretoo": true}}
Returns a new object.
Required
Type: object
The object which keys will be replaced.
Required
Type: string
or RegExp
Search for matching substring that will be replaced.
Required
Type: string
Replace the matching substring with this value.
Because Elasticsearch doesn't like dots in field names...
https://www.elastic.co/guide/en/elasticsearch/reference/2.4/dots-in-names.html
MIT © Petar Bojinov