Skip to main content

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

Project details


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)

Uploaded Source

Built Distribution

hopy-0.0.2-py3-none-any.whl (10.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page