unflatten-recursive
v1.0.1
Published
Unflattens object recursively while preserving arrays. Contents of arrays are also unflattened.
Downloads
6
Maintainers
Readme
unflatten-recursive
Unflattens object recursively while preserving arrays. Contents of arrays are unflattened.
Note: UNLIKE OTHER OPEN SOURCE LIB such as flat
, this lib also loops through arrays and unflattens
the array members recursively.
Input:
{
'key.nestedKey': 'value',
'key.arr': [{a : 'a'}, 1, {'arrKey.nestedArrKey': 'arrValue'}]
}
Output:
{
key: {
nestedKey: 'value',
arr: [{a: 'a'}, 1, {arrKey: {nestedArrKey: 'arrValue'}}]
}
}
For more examples see test/spec.js
Installation
npm install --save unflatten-recursive
Usage
import unflattenRecursive from 'unflatten-recursive';
unflattenRecursive({
'a.b.c': 'something'
}); // {a: {b: {c: 'something'}}}
unflattenRecursive({
'a.b': [
{'c.d': 'nested'}
]
}); // {a: {b: [{c: {d: 'nested'}}]}}