Strange behaviour when a key is like E[0-9]*
joakinen opened this issue · comments
Joaquín Herrero Pintado commented
Hi,
It seems that if a key starts with the letter "E" and the rest of the key name consists of numbers that key is processed as an error.
$ jq --version
jq-1.5
$ echo "{\"S0\":\"bar\"}" | jq .S0
"bar"
$ echo "{\"E0\":\"bar\"}" | jq .E0
jq: error: Invalid numeric literal at EOF at line 1, column 3 (while parsing '.E0') at <top-level>, line 1:
.E0
jq: 1 compile error
pkoppstein commented
Thanks for reporting the bug. As you've noticed, jq tries to parse tokens such as .E0
, .e0
, .e1
, etc, as numbers and hence the error message.
For those seeking a workaround, it is, as always with problematic key names, to use the primary accessor syntax:.["KEY"]
Alan Wang commented
hi @joakinen
The scenario you mentioned can already be handled correctly.you can try it in master branch.
root@os-001: echo '{"a0":123}' | jq .a0
123
root@os-001: echo '{"C0":123}' | jq .C0
123
root@os-001: echo '{"R0123":123}' | jq .R0123
123
Nico Williams commented
Yes, this is a bug, and a dup of a number of earlier bugs.