Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONPath $..book[0,1] fails - Parse error at 1:9 near token , (,) #8

Open
Tset-Noitamotua opened this issue Oct 8, 2017 · 2 comments
Labels
Bug in dependencies The bug is not in the API code but in one of the dependencies

Comments

@Tset-Noitamotua
Copy link

How to reproduce

Use JSON data (bookstore.json) and RF test case (bookstore.robot) from issue #7
but replace test case with this one:

Get the first two books
    Get Value From Json    ${bookstore_data}    $..book[0,1]

Result

Parse error at 1:9 near token , (,)	
14:53:23.052	DEBUG	Traceback (most recent call last):
  File "c:\python_virtual_envs\api_requests\lib\site-packages\JSONLibrary\JSONLibraryKeywords.py", line 77, in get_value_from_json
    json_path_expr = parse(json_path)
  File "c:\python_virtual_envs\api_requests\lib\site-packages\jsonpath_rw_ext\parser.py", line 179, in parse
    return ExtentedJsonPathParser(debug=debug).parse(path)
  File "c:\python_virtual_envs\api_requests\lib\site-packages\jsonpath_rw\parser.py", line 32, in parse
    return self.parse_token_stream(lexer.tokenize(string))
  File "c:\python_virtual_envs\api_requests\lib\site-packages\jsonpath_rw\parser.py", line 55, in parse_token_stream
    return new_parser.parse(lexer = IteratorToTokenStream(token_iterator))
  File "c:\python_virtual_envs\api_requests\lib\site-packages\ply\yacc.py", line 331, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "c:\python_virtual_envs\api_requests\lib\site-packages\ply\yacc.py", line 1199, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "c:\python_virtual_envs\api_requests\lib\site-packages\ply\yacc.py", line 193, in call_errorfunc
    r = errorfunc(token)
  File "c:\python_virtual_envs\api_requests\lib\site-packages\jsonpath_rw\parser.py", line 69, in p_error
    raise Exception('Parse error at %s:%s near token %s (%s)' % (t.lineno, t.col, t.value, t.type))
@Tset-Noitamotua
Copy link
Author

... working alternative with slice

Get the first two books
    # Get Value From Json    ${bookstore_data}    $..book[0,1]  > fails, see above
    Get Value From Json    ${bookstore_data}    $..book[:2]       # wokrs

@elrandira
Copy link
Collaborator

Known issue from the parser: h2non/jsonpath-ng#28

@elrandira elrandira added Bug in dependencies The bug is not in the API code but in one of the dependencies and removed wontfix labels Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug in dependencies The bug is not in the API code but in one of the dependencies
Projects
None yet
Development

No branches or pull requests

2 participants