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

Single quotes are not supported #31

Open
rob-chkk opened this issue Jun 8, 2022 · 1 comment
Open

Single quotes are not supported #31

rob-chkk opened this issue Jun 8, 2022 · 1 comment

Comments

@rob-chkk
Copy link

rob-chkk commented Jun 8, 2022

The JSONPath standard supports single-quotes for bracket notation (see here) but they fail with a syntax error:

m := map[string]interface{}{
  "field": map[string]interface{}{
    "sub-field": "hello",
  },
}
value, err := jsonpath.Get("$.field['sub-field']", m) 
// err is incorrectly set to `could not parse string: invalid syntax`

// the following case works correctly:
value, err := jsonpath.Get("$.field[\"sub-field\"]", m) 
// err is nil, value is "hello"

Instead I'd expect this to work correctly.

@JanHoefelmeyer
Copy link

JanHoefelmeyer commented Jul 7, 2023

This seems to be an issue of the Gval library, which is using the text/scanner go library, which does not use single quotes to indicate strings and as such throws an error. In go, single quotes indicate single characters only. As such, it's unlikely that text/scanner will be changed to accommodate this issue and should probably be solved in Gval.

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

No branches or pull requests

2 participants