https://github.com/santanusinha/hope
Predicate expression language
https://github.com/santanusinha/hope
filter filtering jackson java json json-path predicate-logic predicates rule-engine rules
Last synced: about 2 months ago
JSON representation
Predicate expression language
- Host: GitHub
- URL: https://github.com/santanusinha/hope
- Owner: santanusinha
- License: apache-2.0
- Created: 2019-02-08T07:15:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-07-22T12:38:50.000Z (3 months ago)
- Last Synced: 2025-07-22T14:39:02.177Z (3 months ago)
- Topics: filter, filtering, jackson, java, json, json-path, predicate-logic, predicates, rule-engine, rules
- Language: Java
- Homepage:
- Size: 347 KB
- Stars: 18
- Watchers: 4
- Forks: 16
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hope [](https://github.com/santanusinha/hope/actions/workflows/build.yml)
Hope is a high level language for predicate evaluation on JSON written in java. It uses jackson for json handling and json-path for value extraction.#### Sample Hope expressions/rules
```
'/val' + 2 > 3
'/a' + '/b' <= math.abs('/c')
```
#### Features
- Simple syntax
- Bunch of rich standard library functions built in
- Performant
- Easy to add custom functions
# Getting started### Maven dependency
Use the following dependency in your code.
```
io.appform.hope
hope-lang
2.0.6
```### Basic usage
The following steps can be used to parse and evaluate a predicate expression or rule.
#### Create HopeLangEngine
The main class you need to know is `HopeLangEngine`. To use this class use the provided builder.
```
final HopeLangEngine hope = HopeLangEngine.builder()
.build();
```
> **Note:** Creation of this class is a time-consuming affair. Create and re-use this. This class is thread-safe.
#### Evaluate an expression
The following code snippet evaluates an expression against a parsed jackson Json node.
```
final JsonNode root = new ObjectMapper().readTree("{\"val\" : 10 }");
final String expr = " '/val' + 2 > 9";
if(engine.evaluate(expr, root)) {
...
}
```> For real life use cases, rule should be parsed only once and cached. Same cached rule can be evaluated multiple times by passing different payloads. See wiki for more details.
# Documentation
Please go through the hope wiki for detailed documentation## License
Hope is licensed under Apache License Version 2.0