Flatten the given object. Given an object with nested elements, it returns an object that has been flattened, that is, where the keys are string that represent the nested route to follow in the original object to access the leaves.
flatten({ a: { a1: 1, a2: 2 }, b: { b1: { b1i: 'hello', b1ii: 'world' } }});// this will yield:{ 'a.a1': 1, 'a.a2': 2, 'b.b1.b1i': 'hello', 'b.b1.b1ii': 'world'} Copy
flatten({ a: { a1: 1, a2: 2 }, b: { b1: { b1i: 'hello', b1ii: 'world' } }});// this will yield:{ 'a.a1': 1, 'a.a2': 2, 'b.b1.b1i': 'hello', 'b.b1.b1ii': 'world'}
Additional options may be passed, such as which character is used as a delimiter, or the maximum depth level.
For an inverse operation see unflatten.
The element to flatten.
The option to flatten.
The flattened object
Flatten the given object. Given an object with nested elements, it returns an object that has been flattened, that is, where the keys are string that represent the nested route to follow in the original object to access the leaves.
Example
Additional options may be passed, such as which character is used as a delimiter, or the maximum depth level.
For an inverse operation see unflatten.