Allow single quotes for Strings to allow parsing JSONPath
Opened this issue · 1 comments
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.
This issue with the corresponding PR#98 is a precondition for fixing PaesslerAG/jsonpath#38 .
@mhengl if you have questions, please let us know! :)