Closed FlanniganColum closed 9 months ago
After reading more i noticed i made a mistake and was not using the .ext, so i have fixed that and now the error i get is. Course the ultimate plan is to have the path name lookup a variable so i can using it dynamically.
Traceback (most recent call last):
File "./loop.py", line 85, in <module>
sys.exit(main(sys.argv[1:]))
File "./loop.py", line 76, in main
jsonpath_expression = parse("$.[*]parents[?(@.name == 'Sample')].name")
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/jsonpath_ng/ext/parser.py", line 172, in parse
return ExtentedJsonPathParser(debug=debug).parse(path)
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/jsonpath_ng/parser.py", line 45, in parse
return self.parse_token_stream(lexer.tokenize(string))
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/jsonpath_ng/parser.py", line 69, in parse_token_stream
return new_parser.parse(lexer = IteratorToTokenStream(token_iterator))
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/ply/yacc.py", line 333, in parse
return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
tok = call_errorfunc(self.errorfunc, errtoken, self)
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/ply/yacc.py", line 192, in call_errorfunc
r = errorfunc(token)
File "/opt/apps/zabbix/zbxSLA/.venv/lib64/python3.6/site-packages/jsonpath_ng/parser.py", line 84, in p_error
% (t.lineno, t.col, t.value, t.type))
jsonpath_ng.exceptions.JsonPathParserError: Parse error at 1:5 near token parents (ID)
Actually i found the solution if i adjusted the syntax to the below it worked for me
jsonpath_expression = parse("$.[*]['parents'][?(@.name == 'Sample')].['name']")
Hey. So i am trying out the jsonpath_ng for the first time and by using the below sample code i am getting the below error. while using the site "https://www.javainuse.com/jsonpath" i am validating the jsonPath syntax and it works fine, do i need to escape the question mark or is this a known issue, and if so do you know a workaround
Package Version
jsonpath-ng 1.6.0