I'm trying to combine the arrays of two JSON files I need to achieve this by combining the arrays without removing existing values of arrays and without removing any object. Sorting output arrays would be nice but not necessary.
file-1.json:
{ "title": { "message": { "receiver": [ "one", "two", "three" ], "sender": [ "two", "one", "one" ] } } } file-2.json:
{ "title": { "message": { "receiver": [ "four", "two", "three" ], "sender": [ "one", "one", "one" ] } } } What I have tried:
$ jq -s 'add' file-1.json file-2.json { "title": { "message": { "receiver": [ "four", "two", "three" ], "sender": [ "one", "one", "one" ] } } } Expected output:
{ "title": { "message": { "receiver": [ "one", "two", "three", "four" ], "sender": [ "one", "two" ] } } }