Flatten a nested object using query string syntax.
npm install q-flat
- 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 }
- Use
npm test
to build and run tests.
Please feel free to create a PR!