I have big json, where i am renaming a nested object .module.home.[].list
member from object_old
to object_new
and then deleting the object_old
key.
cat out.json{ ... {"objecta": {"field1": 1,"field2": 2 },"objectb": {"field1": 1,"field2": 2 },"object_old": {"field1": 1,"field2": 2 } } ...}jq ".module.home.[].list | .object_new = .object_old | del(.object_old)" out.json{"objecta": {"field1": 1,"field2": 2 },"objectb": {"field1": 1,"field2": 2 },"object_new": {"field1": 1,"field2": 2 }}
Now, while i was able to update .module.home.[].list
, i only have the updated sub object in the output. How can i get the entire json back with the updated object_new
, so i can save it back to out.json