Skip to content

JSON path parser fails to parse comma-separated array indexes #169

Open
@aovchinnikov

Description

@aovchinnikov

Env:

  • Windows 10
  • Python 3.8.10
  • jsonpath-ng 1.6.1

The following code returns parser error:

from jsonpath_ng.ext import parse

jsonpath_expr = parse('$.commands[0,1].test_prop')

jsonpath_expr = parse('$.commands[0,1].tester') File "C:\Python38\lib\site-packages\jsonpath_ng\ext\parser.py", line 174, in parse return ExtentedJsonPathParser(debug=debug).parse(path) File "C:\Python38\lib\site-packages\jsonpath_ng\parser.py", line 38, in parse return self.parse_token_stream(lexer.tokenize(string)) File "C:\Python38\lib\site-packages\jsonpath_ng\parser.py", line 62, in parse_token_stream return new_parser.parse(lexer = IteratorToTokenStream(token_iterator)) File "C:\Python38\lib\site-packages\ply\yacc.py", line 333, in parse return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) File "C:\Python38\lib\site-packages\ply\yacc.py", line 1201, in parseopt_notrack tok = call_errorfunc(self.errorfunc, errtoken, self) File "C:\Python38\lib\site-packages\ply\yacc.py", line 192, in call_errorfunc r = errorfunc(token) File "C:\Python38\lib\site-packages\jsonpath_ng\parser.py", line 78, in p_error raise JsonPathParserError('Parse error at %s:%s near token %s (%s)' jsonpath_ng.exceptions.JsonPathParserError: Parse error at 1:12 near token , (,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions