A high level language for predicate evaluation on JSON using JsonPath expressions
Project description
hopy
A high level language for predicate evaluation on JSON using JsonPath expressions
Getting started
Prerequisites
- python3.7+
Installation
- Install the package using pip.
pip install hopy[jsonpath_ng]
Usage
from hopy.evaluator import HopyEvaluator
rule_payload = {
"str": "Hello World!",
"num": 1337,
"float": 13.37,
"nested": {
"str": "Hello again!"
}
}
rule = '`$.str` == "Hello World!" && (`$.num` == 1337 || `$.float` < 13) && f.in(f.lower(`$.nested.str`), "hello")'
rule_evaluator = HopyEvaluator(rule)
rule_evaluator.evaluate(rule_payload) # True
License
This project is licensed under the Apache License - see the LICENSE.md file for details
Acknowledgements
- Inspired from santanusinha/hope
- Default JsonPath implementation jsonpath-ng
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hopy-0.0.2.tar.gz
(5.6 kB
view hashes)
Built Distribution
hopy-0.0.2-py3-none-any.whl
(10.4 kB
view hashes)