dchester / jsonpath

Query and manipulate JavaScript objects with JSONPath expressions. Robust JSONPath engine for Node.js.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

$..[(')]')] Trips Up the Parser

movitto opened this issue · comments

See Pull Request #142 for a potential (less than optimal) fix.

The grammer as it is defined will encounter the ')]' in the single-quotes and use this as the end of the filter expression. When it encounters the second single-quote jison will throw a lexical error yielding 'unrecognized text'.

Pull request #142 enables greedy matching which will match the expression to the end resolving this issue but introducing another in the case of mulitple filter expressions, eg

$..[?('expr1')][?('expr2')]

Opening this up to start the discussion and see if any others can determine a solution that works in both cases

Parser should expose a function to sanitize dynamic input in order to not break the parsing phase. I used some token in my Golden Path parser.

See the v() function