I would like to assign different values to a same field in a json array using jq command line utility,
for example let's take this:
myjson='[{"a":1,"b":"john"}, {"a":2, "b":"mark"}]'with the following I can assign all fields a same value
echo $myjson | jq '[.[] | .a=5 ]'I can also increment it:
echo $myjson | jq '[.[] | .a+=2]'but how can I assign two new different values like 7 and 3 to the two a fields in the objects in the array?
using the following, or similar assigns a whole array to each variable
echo $myjson | jq '[.[] | .a=[7,3]]'