sileht / python-jsonpath-rw-ext

Extensions for JSONPath RW
Apache License 2.0
59 stars 19 forks source link

How to use Extensions filter? #26

Open ivanli1990 opened 5 years ago

ivanli1990 commented 5 years ago

There are some examples for Extensions filter. eg:

$.objects[?(some_field ~ “regexp”)]

But, I don't know how to use it in the code.

from jsonpath_rw_ext import match1
d = {'date': {'d': '2019'}}
res = match1('$.date[?(d ~ ".*")]', d)
print(res) # console None

In my test code above, the console is None. So, how to use Extensions filter? Could examples be written in more detail?

casperdcl commented 4 years ago

same issue: jp.match('$[?(@.a=10)]', {'m': {'a': 10}, 'n': {'a': 20}}) is empty