I want to transform json to new line delimited json. I was attempting to do it multiple times using jq in bash, but I have not been able to get even close to the final output.
INPUT:
{
"windows124": {
"updated": "2015-01-14",
"attribution": [],
"description": "",
"notes": [],
"alt_names": [],
"sources": [],
"urls": ["google.com", "google.co.uk"],
"common_name": "test",
"uuid": "7259334c-3218-4259-aaab-896d87507f4f"
},
"linux124": {
"updated": "",
"attribution": ["Naifdddkoscn"],
"description": "",
"notes": [],
"alt_names": [],
"sources": [],
"urls": ["https://example.com/1.pdf", "https://example.com/1.pdf", "https://example.com/1.pdf"],
"common_name": "121212",
"uuid": "009db412-762d-4256-8df9-eb213be01ffd"
},
"wikipedia123": {
"updated": "2018-07-31",
"attribution": [],
"description": "",
"notes": [],
"alt_names": [],
"sources": [],
"urls": ["https://example.com/1.pdf"],
"common_name": "test343",
"uuid": "4d8da0af-cfd7-4990-b211-af0e990vfda0"
}
}
WANTED OUTPUT:
{"uuid": "7259334c-3218-4259-aaab-896d87507f4f","family": "windows124","updated": "2015-01-14","attribution": [],"description": "","notes": [],"alt_names": [],"sources": [],"urls": ["google.com", "google.co.uk"],"common_name": "test"}
{"uuid": "009db412-762d-4256-8df9-eb213be01ffd","family": "linux124", "updated": "","attribution": ["Naifdddkoscn"],"description": "","notes": [],"alt_names": [],"sources": [],"urls": ["https://example.com/1.pdf", "https://example.com/1.pdf", "https://example.com/1.pdf"],"common_name": "121212"}
{"uuid": "4d8da0af-cfd7-4990-b211-af0e990vfda0","family": "wikipedia123", "updated": "2018-07-31","attribution": [],"description": "","notes": [],"alt_names": [],"sources": [],"urls": ["https://example.com/1.pdf"],"common_name": "test343"}
What I have so far is: cat deserialize.json | jq -c '.|to_entries[]'
{"key":"windows124","value":{"updated":"2015-01-14","attribution":[],"description":"","notes":[],"alt_names":[],"sources":[],"urls":["google.com","google.co.uk"],"common_name":"test","uuid":"7259334c-3218-4259-aaab-896d87507f4f"}}
{"key":"linux124","value":{"updated":"","attribution":["Naifdddkoscn"],"description":"","notes":[],"alt_names":[],"sources":[],"urls":["https://example.com/1.pdf","https://example.com/1.pdf","https://example.com/1.pdf"],"common_name":"121212","uuid":"009db412-762d-4256-8df9-eb213be01ffd"}}
{"key":"wikipedia123","value":{"updated":"2018-07-31","attribution":[],"description":"","notes":[],"alt_names":[],"sources":[],"urls":["https://example.com/1.pdf"],"common_name":"test343","uuid":"4d8da0af-cfd7-4990-b211-af0e990vfda0"}}
-c(--compact-output) command line option if you don't want the output pretty-printed