The command:
jq ."1" example.json
doesn't work because the quotes are interpreted by the shell and the first argument that jq
receives is .1
. The command above is identical to jq .1 example.json
and it is not correct as jq
reports.
You need to enclose the jq
program in apostrophes to prevent the shell interpret any character in it:
jq '."1"' example.json
This way, jq
receives ."1"
as its program and happily interprets it.
You can also put the key name into square brackets (as you have already tried) but it doesn't add any improvement, it's the same program only bloated. And it gives you more reasons to put it into apostrophes to protect it from the shell:
jq '.["1"]' example.json