jq

Reading Fields

jq ".a.b.c" # retrieve item at {a: {b: {c: …}}}
jq -r … # output strings raw, without quotes
jq … in.ext # read in from a file
[cmd] | jq # pipe in content to read
VAR=$(jq …) # assign result to VAR

Updating Fields

jq ".a.b.c" |= "newvalue" # update value at a.b.c
jq ".a" |= "new" | ".b" |= "new" # update two fields

# To overwrite a file, easiest to move it to a temp location,
# then write back to the original location:
mv file.ext file.ext.temp
jq … file.ext.temp > file.ext
rm file.ext.temp