2017-07-18 47 views
1

我安裝jsonpath-RW 1.4.0與Python的JSONPath過濾表達式的錯誤,對jsonpath-RW意外的字符1.4.0

sudo apt-get install python-jsonpath-rw

,它有一個/usr/bin/jsonpath。但是,這是給我使用過濾器表達式時的錯誤:

$ jsonpath '$..book[?(@.price < 10)]' book.json 
Traceback (most recent call last): 
    File "/usr/bin/jsonpath", line 11, in <module> 
    load_entry_point('jsonpath-rw==1.4.0', 'console_scripts', 'jsonpath.py')() 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/bin/jsonpath.py", line 71, in entry_point 
    main(*sys.argv) 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/bin/jsonpath.py", line 57, in main 
    expr = parse(args.expression) 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/parser.py", line 14, in parse 
    return JsonPathParser().parse(string) 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/parser.py", line 32, in parse 
    return self.parse_token_stream(lexer.tokenize(string)) 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/parser.py", line 55, in parse_token_stream 
    return new_parser.parse(lexer = IteratorToTokenStream(token_iterator)) 
    File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 331, in parse 
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) 
    File "/usr/lib/python2.7/dist-packages/ply/yacc.py", line 1061, in parseopt_notrack 
    lookahead = get_token()  # Get the next token 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/parser.py", line 179, in token 
    return next(self.iterator) 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/lexer.py", line 33, in tokenize 
    t = new_lexer.token() 
    File "/usr/lib/python2.7/dist-packages/ply/lex.py", line 393, in token 
    newtok = self.lexerrorf(tok) 
    File "/usr/lib/python2.7/dist-packages/jsonpath_rw/lexer.py", line 165, in t_error 
    raise JsonPathLexerError('Error on line %s, col %s: Unexpected character: %s ' % (t.lexer.lineno, t.lexpos - t.lexer.latest_newline, t.value[0])) 
jsonpath_rw.lexer.JsonPathLexerError: Error on line 1, col 8: Unexpected character: ? 

那麼jsonpath-rw 1.4.0不支持過濾器表達式?

這似乎是working fine according to this blog post,但這是在2015年

自那時以來情況發生了變化?

+0

你知道嗎?我遇到了同樣的問題。 – Mike

+0

感謝您的確認@Mike。我很高興它不僅僅是我。我還沒有考慮到它,而且很可能它永遠不會發生。你能在那裏記錄一個錯誤嗎? – xpt

回答

1

我通過使用jsonpath-rw-ext而不是jsonpath-rw得到了這個工作。這似乎是支持過濾器擴展的一個。

相關問題