h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
582 stars 85 forks source link

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

Open dgDSA opened 2 weeks ago

dgDSA commented 2 weeks ago

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.