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

Enclosing member names in JSONPath #311

Closed
0x777 opened this issue Oct 29, 2015 · 2 comments
Closed

Enclosing member names in JSONPath #311

0x777 opened this issue Oct 29, 2015 · 2 comments

Comments

@0x777
Copy link

0x777 commented Oct 29, 2015

Current, aeson-0.10.0.0

Prelude M A> A.eitherDecode "{\"a.b\" : \"c\"}" :: Either String (M.HashMap String Int)
Left "Error in $.a.b: expected Int, encountered String"

Expected [ref]

Prelude M A> A.eitherDecode "{\"a.b\" : \"c\"}" :: Either String (M.HashMap String Int)
Left "Error in $.['a.b']: expected Int, encountered String"

A key, regardless of its contents, if defensively enclosed as ['key'], solves this problem. Otherwise, presence of . can be tested and key can be enclosed accordingly.

@bergmark
Copy link
Collaborator

I think this makes sense, I'd like keys to only be escaped if they contain a period.

@phadej
Copy link
Collaborator

phadej commented Feb 2, 2016

I guess it makes sense to escape if the key isn't valid jsonpath identifier (cannot find a grammar by quick googling). At least ['escapeme'] key should be escaped (how?).

EDIT https://github.com/stevenalexander/antlr4-jsonpath-grammar/blob/master/JsonPath.g4 says INDENTIFIER : [a-zA-Z][a-zA-Z0-9]* ;

bergmark added a commit that referenced this issue Feb 4, 2016
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

3 participants