q-flat
v1.0.7
Published
Flatten a nested object using query string syntax.
Downloads
16,393
Maintainers
Readme
Flatten a nested object using query string syntax.
Installation
Npm
npm install q-flat
API
qflat.flatten(obj: any): any
- Converts a nested object into a shallow one with keys using query string syntax.
import { flatten } from 'q-flat';
// Flatten nested objects.
flatten({ a: { b: { c: { 1 } } }); // -> { "a[b][c]": 1 }
// Even flatten arrays.
flatten({ a: [{ b: 1 }, { c: 2 }] }); // -> { 'a[0][b]': 1, 'a[1][c]': 2 }
Contributions
- Use
npm test
to build and run tests.
Please feel free to create a PR!