diff --git a/jsonpath_rw_ext/parser.py b/jsonpath_rw_ext/parser.py index db265e5..07c5382 100644 --- a/jsonpath_rw_ext/parser.py +++ b/jsonpath_rw_ext/parser.py @@ -28,9 +28,8 @@ class ExtendedJsonPathLexer(lexer.JsonPathLexer): """Custom LALR-lexer for JsonPath""" literals = lexer.JsonPathLexer.literals + ['?', '@'] tokens = (parser.JsonPathLexer.tokens + - ['FILTER_OP', 'FILTER_VALUE', 'SORT_DIRECTION']) + ['FILTER_OP', 'SORT_DIRECTION']) - t_FILTER_VALUE = r'\w+' t_FILTER_OP = r'(==?|<=|>=|!=|<|>)' def t_SORT_DIRECTION(self, t): @@ -66,7 +65,6 @@ class ExtentedJsonPathParser(parser.JsonPathParser): def p_expression(self, p): """expression : jsonpath - | jsonpath FILTER_OP FILTER_VALUE | jsonpath FILTER_OP ID | jsonpath FILTER_OP NUMBER """ diff --git a/jsonpath_rw_ext/tests/test_jsonpath_rw_ext.py b/jsonpath_rw_ext/tests/test_jsonpath_rw_ext.py index 108db97..0ff7a47 100644 --- a/jsonpath_rw_ext/tests/test_jsonpath_rw_ext.py +++ b/jsonpath_rw_ext/tests/test_jsonpath_rw_ext.py @@ -61,6 +61,10 @@ class TestJsonpath_rw_ext(testscenarios.WithScenarios, data={'objects': [{'cow': 'moo'}, {'cat': 'neigh'}]}, target=[{'cow': 'moo'}])), + ('filter_exists_syntax4', dict(string='objects[?(@."cow!?cat")]', + data={'objects': [{'cow!?cat': 'moo'}, + {'cat': 'neigh'}]}, + target=[{'cow!?cat': 'moo'}])), ('filter_eq1', dict(string='objects[?cow="moo"]', data={'objects': [{'cow': 'moo'}, {'cow': 'neigh'},