file1:
{
"status": {
"errorCode": 0,
"recordsTotal": 6,
"recordsInResponse": 2
},
"records": [
{
"itemID": 128,
"name": "foo barn"
},
{
"itemID": 64,
"name": "fee fom"
}
]
}
file2:
{
"status": {
"errorCode": 0,
"recordsTotal": 6,
"recordsInResponse": 2
},
"records": [
{
"itemID": 32,
"name": "pim pom"
},
{
"itemID": 256,
"name": "ping pong"
}
]
}
wanted:
"records": [ // records array is not needed, having just items iterated is fine as well.
{
"itemID": 128,
"name": "foo barn"
},
{
"itemID": 64,
"name": "fee fom"
},
{
"itemID": 32,
"name": "pim pom"
},
{
"itemID": 256,
"name": "ping pong"
}
]
From what I have tried, I have dismissed filtering the records, focused on only combining the files.
I'm not very knowlegable with jq
. I got the nearest results with:
jq -s '.[0] += .[1]'
jq -s '.[0] |= . + .[1]'
How do I merge 2 json files, probably with jq
?