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

Allow single quotes for Strings to allow parsing JSONPath #97

Open
JanHoefelmeyer opened this issue Jul 14, 2023 · 1 comment
Open

Allow single quotes for Strings to allow parsing JSONPath #97

JanHoefelmeyer opened this issue Jul 14, 2023 · 1 comment

Comments

@JanHoefelmeyer
Copy link

As indicated in PaesslerAG/jsonpath#38, Gval has trouble evaluating some JSONPath expressions since its syntax in that point conflicts with Go syntax:

Strings in Go are portrayed by double-quotes "..." and as
raw-strings ... . Single-quoted-strings '...' are not known in Go. Instead, they are used to indicate single characters and runes. This means, when Gval encounters single-quotes strings, it will try to parse it as a single character and fail, throwing an error.

This is because Gval uses the text/scanner as is. To solve this issue, there could be an option to allow for alternate parsing, which would take single quotes or similar into account. Instead of the text/scanner package, a custom, similar lexer could be used.

Addtionally, the strconv.Unquote functionality is also based on Go, and as such will not accept single-quoted strings. As such, the parseString-method could be adjusted as well, so that it transforms single-quoted strings into double-quoted strings, allowing them to be parsed.

These changes could be made optional as to not disrupt potential workflows that already depend on jsonpath not evaluating single quoted strings.

@bernhardreiter
Copy link

This issue with the corresponding PR#98 is a precondition for fixing PaesslerAG/jsonpath#38 .

@mhengl if you have questions, please let us know! :)

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