I have a Json file named some_file.json
:
{
"dog": {
"breed_1": 12,
"breed_2": 20,
},
"cat": {
"breed_1": 6,
"breed_2": 8,
},
}
I want to convert it to the below json lines file:
{"dog":{"breed_1":12,"breed_2":20}}
{"cat":{"breed_1":6,"breed_2":8}}
Notice, how every key value in the original JSON is now on a single line.
I can write some code for this in any programming language. But I was wondering how I can use jQ to convert the JSON to a JSON lines file.
I tried, cat some_file.json | jq '.[]' -c > lines_file.jsonl
and it returned
{"breed_1": 12, "breed_2": 20}
{"breed_1": 6, "breed_2": 8}
The dog
and cat
key vanish.