You are given a JSON-like value representing an object that may contain:
Return a flattened map from path to primitive value.
.
to join object keys.
[i]
for array indices.
Input
{
"a": 1,
"b": {"c": 2, "d": [3, 4]},
"e": [ {"f": 5}, 6 ]
}
Output
a -> 1
b.c -> 2
b.d[0] -> 3
b.d[1] -> 4
e[0].f -> 5
e[1] -> 6
.
and
[
]
(you may assume this to avoid escaping).
string -> primitive
.
Implement a function to perform this flattening.