Replies: 1 comment
|
jq -c 'to_entries[] | {(.key): .value}' input.json > output.jsonlOr the equivalent with jq -c 'keys_unsorted[] as $k | {($k): .[$k]}' input.json > output.jsonlExample: $ jq -c 'to_entries[] | {(.key): .value}' <<'JSON'
{
"18003432343": {"04:00:25": {"x": 1}},
"18005553332": {"18:11:25": {"y": 2}}
}
JSONNotes:
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have JSON that looks like:
If I convert the above to JSONL using
jq -c '.[]' input.json > output.jsonl, I get the following in the output JSONL:I lose the top level keys that were in my original JSON file. I am looking for output that preserves those keys - which would look like:
What is the appropriate JQ command for this?
All reactions