I have a JSON data file (as shown below) and I\'m trying to find field values using jq utility.
It\'s working fine except for fields if the key name contains a
Hm..took some time but finally it seems like we need to DOUBLE QUOTE it and back slash just the double quote for any key name containing a - in it's name.
$ cat /tmp/my.data.json| jq ".content.book1.\"field-2\""
"value-2"
$ cat /tmp/my.data.json| jq ".content.book1.\"field-three\".\"url\""
"book1/field-three/"
OR
if you wrap everything in a single quotes ', then we do NOT need to backslash " double quotes but use double quotes for key names with - in their name.
$ cat /tmp/my.data.json| jq '.content.book1."field-three"."url"'
"book1/field-three/"
Hope it helps! Took some help/hint from https://jqplay.org/
See this for more: https://github.com/stedolan/jq/issues/38#issuecomment-9770240