sileht / python-jsonpath-rw-ext

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

Added support for boolean values in filters #11

Closed ernoc closed 7 years ago

ernoc commented 7 years ago

Filtering with boolean values now supported.

Boolean values are expressed as true and false as json.

Examples:

import jsonpath_rw_ext

data = [{"color": "blue", "flag": True}, {"color": "green", "flag": False}]

jsp = jsonpath_rw_ext.parse("$[?flag = true].color")
print [match.value for match in jsp.find(data)]
# prints ['blue']

jsp = jsonpath_rw_ext.parse("$[?flag = false].color")
print [match.value for match in jsp.find(data)]
# prints ['green']

Strings "true" and "false" can still be matched using quotes.

Closes #10 .

sileht commented 7 years ago

That looks good! Thanks a lot!