sqlitebiter
sqlitebiter copied to clipboard
Flatten JSON
Flatten JSON which has JSON schema format currently not supported before converting.
Poll: https://github.com/thombashi/sqlitebiter/discussions/89
I do this by pre-processing my files with jq. Give the following:
flatten.json:
[
{
"a": {
"b": 1,
"c": 2
}
},
{
"a": {
"b": 3,
"c": 4
}
}
]
flatten.jq:
map([ leaf_paths as $path | { key: $path|join("."), value: getpath($path) } ]|from_entries)
the command jq -f flatten.jq flatten.json
will produce the following output:
[
{
"a.b": 1,
"a.c": 2
},
{
"a.b": 3,
"a.c": 4
}
]
https://github.com/thombashi/sqlitebiter/discussions/89