I have the following two json files and I am trying to merge the DEV object.
jsonFile1:
{
"ENV": {
"DEV": {},
"ST": {
"middleware": [],
"system": [],
"application": [],
"utility": []
},
"ESIT": {
"middleware": [],
"system": [],
"application": [],
"utility": []
}
}
}
jsonFile2:
{
"ENV": {
"DEV": {
"middleware": [],
"system": [],
"application": [
{
"artefact": "abc",
"domain": "df",
"hostname": "sfa"
},
{
"artefact": "awe",
"domain": "csd",
"hostname": "wer"
}
],
"utility": []
}
}
}
Expected Resulting Json Fi:
{
"ENV": {
"DEV": {
"middleware": [],
"system": [],
"application": [
{
"artefact": "abc",
"domain": "df",
"hostname": "sfa",
},
{
"artefact": "awe",
"domain": "csd",
"hostname": "wer",
}
],
"utility": []
},
"ST": {
"middleware": [],
"system": [],
"application": [],
"utility": []
},
"ESIT": {
"middleware": [],
"system": [],
"application": [],
"utility": []
}
}
}
I have already tried:
jq -s '.ENV["DEV"][] * .ENV["DEV"][]' jsonFile1.json jsonFile2.json
However that raises the error 'Cannot index array with string "ENV"'. I can also delete the '"DEV": {}' object out of jsonFile1 if that makes the merging process any easier.