I have a json file named xyz.json as follows
[
{
"annotations": [ "a" , "b" , "c" ],
"class": "image",
"filename": "vc00_02201.png"
},
{
"annotations": [],
"class": "image",
"filename": "vc00_02202.png"
}
{
"annotations": [],
"class": "image",
"filename": "vc00_02203.png"
},
{
"annotations": [],
"class": "image",
"filename": "vc00_02204.png"
}
]
I need to copy the object "annotations" from "filename": "vc00_02201.png" to "annotations" of "filename": "vc00_02204.png" within the same xyz.json file using a shell script. Expected output:
[
{
"annotations": [ "a" , "b" , "c" ],
"class": "image",
"filename": "vc00_02201.png"
},
{
"annotations": [],
"class": "image",
"filename": "vc00_02202.png"
}
{
"annotations": [],
"class": "image",
"filename": "vc00_02203.png"
},
{
"annotations": [ "a" , "b" , "c" ],
"class": "image",
"filename": "vc00_02204.png"
}
]
jq
?