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

error: syntax error, unexpected QQSTRING_START, expecting $end #273

Closed
brewingcode opened this issue Jan 21, 2014 · 6 comments
Closed

error: syntax error, unexpected QQSTRING_START, expecting $end #273

brewingcode opened this issue Jan 21, 2014 · 6 comments

Comments

@brewingcode
Copy link

This is with jq v1.3 on OSX 10.9.1.

I'm unable to access a hash key with a double-quoted string (the key contains special characters). A trivial example shows:

$ echo '{"foo": "bar"}' | jq .foo    # without quotes works just fine
"bar"
$ echo '{"foo": "bar"}' | jq '."foo"'    # quoting causes a syntax error
error: syntax error, unexpected QQSTRING_START, expecting $end
."foo"
^
1 compile error

The manual shows almost this exact case:

image

@brewingcode
Copy link
Author

Reading through other issues, as well as the manual, and saw the slightly longer .["foo$"] notation. That works. Manual must be out of date.

@schmichael
Copy link

This should be reopened as the docs are still wrong (or the code still has a bug).

@lluchs
Copy link

lluchs commented Apr 16, 2014

In fact, the docs are too new here - you have to compile jq yourself from master to get the ."foo" notation.

@mgol
Copy link

mgol commented Oct 17, 2016

The syntax .foo."bar-baz" worked for me with latest jq (1.5), the one .foo.["bar-baz"] didn't. It seems the docs are incorrect?

@lluchs
Copy link

lluchs commented Oct 17, 2016

Try removing the last dot: .foo["bar-baz"]

@pkoppstein
Copy link
Contributor

pkoppstein commented Oct 17, 2016

@mgol - You are correct that .foo.["bar-baz"] is not supported in 1.5; if you wanted to use the square-bracket notation, you could revert to the more basic expression .foo | .["bar-baz"], or the abbreviated form: .foo["bar-baz"]

The square-bracket notation (i.e. .[ ACCESSOR ] where ACCESSOR is an expression that evaluates to a JSON string or integer) is actually the fundamental one (i.e. supported by jq 1.3, 1.4, 1.5 and possibly others).

Could you please specify exactly which part of the documentation you believe to be incorrect?

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

No branches or pull requests

6 participants