Given a nested object that may contain both objects and arrays, flatten it into a single-level object.
- Use dot notation to represent nested keys
- For arrays, use the index as the key
- The structure depth can be arbitrary
Input:
{
a: { b: 6, d: { k: 90 } },
x: [9, { m: 0 }]
}
Expected Output :
{
"a.b": 6,
"a.d.k": 90,
"x.0": 9,
"x.1.m": 0
}