Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour when a key is like E[0-9]* #1651

Closed
joakinen opened this issue Apr 18, 2018 · 3 comments · Fixed by #2254
Closed

Strange behaviour when a key is like E[0-9]* #1651

joakinen opened this issue Apr 18, 2018 · 3 comments · Fixed by #2254
Labels
Milestone

Comments

@joakinen
Copy link

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
Copy link
Contributor

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"]

@Alanscut
Copy link
Contributor

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

@nicowilliams
Copy link
Contributor

Yes, this is a bug, and a dup of a number of earlier bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants