Skip to content

JsonPathParserError when property name starts with "true" or "false #177

@dgDSA

Description

@dgDSA

A JsonPathParserError is raised when a JsonPath property starts with the word "true" or "false", e.g.:

Python 3.10.13 (main, Apr 22 2024, 14:22:37) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import jsonpath_ng, jsonpath_ng.ext
jsonpath_ng.version
'1.6.1'
jsonpath_ng.ext.parser.parse("trueName")
Traceback (most recent call last):
File "", line 1, in
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/jsonpath_ng/ext/parser.py", line 174, in parse
return ExtentedJsonPathParser(debug=debug).parse(path)
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/jsonpath_ng/parser.py", line 38, in parse
return self.parse_token_stream(lexer.tokenize(string))
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/jsonpath_ng/parser.py", line 62, in parse_token_stream
return new_parser.parse(lexer = IteratorToTokenStream(token_iterator))
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/ply/yacc.py", line 333, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/ply/yacc.py", line 1201, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/ply/yacc.py", line 192, in call_errorfunc
r = errorfunc(token)
File "/home/dg/ConnectedVehicle.git/pyotx/_3rdparty/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:0 near token True (BOOL)

Note: I found the bug while testing corner cases. Thus, this bug report is very low priority for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions