Convert flatten objects in nested ones.
$ npm i --save obj-unflatten
const unflatten = require("obj-unflatten");
console.log(unflatten({
"name.first": "Johnny"
, "name.last": "B."
, age: 20
}));
// { name: { first: 'Johnny', last: 'B.' }, age: 20 }
// Custom separator
console.log(unflatten({
"name-first": "Johnny"
, "name-last": "B."
, age: 20
}, "-"));
// { name: { first: 'Johnny', last: 'B.' }, age: 20 }
Convert flatten objects in nested ones.
- Object
flatten
: The flatten object that should be converted. - Object
separator
: The field separator (default:"."
).
- Object Unflatten object
Have an idea? Found a bug? See how to contribute.
obj-flatten
– Convert nested objects in flatten ones.