A powerful .NET library for evaluating string-based predicate expressions against JSON objects using JSONPath syntax.
- JSONPath Support: Access
nested
object properties usingdot
notation - Multiple Operators:
eq
(equal),in
(contains),not
(not equal),gt
(greater than),gte
(greater than or equal),lt
(less than),lte
(less than or equal) - Logical Operators:
and
,or
with proper precedence handling - Type Safety:
Automatic
type conversion and validation - Complex Expressions:
Parentheses
grouping andnested
operations - Lightweight:
Minimal
dependencies,fast
evaluation
Install via NuGet Package Manager:
Install-Package JsonPathPredicate
The library provides a powerful, flexible way to evaluate complex conditional logic against JSON objects, making it ideal for business rules, filtering, validation, and many other use cases in .NET applications.
Please see wiki for comprehensive documentation to integrate JSONPathPredicate in your project.
The expression syntax is ([JSONPath] [Comparison Operator] [Value]) [Logical Operator] ([JSONPath] [Comparison Operator] [Value])
- Comparison Operators -
eq
,in
,gt
,gte
,lt
,lte
&Not
- Logical Operators -
and
&or
var customer = new {
client = new {
address = new {
postcode = "e113et",
number = 123,
active = true
},
tags = new[] { "vip", "premium" }
},
score = 95.5
};
bool result1 = JSONPredicate.Evaluate("client.address.postcode eq `e113et`", customer);
bool result2 = JSONPredicate.Evaluate("client.address.postcode eq `e113et` and client.address.number eq 123", customer);
bool result3 = JSONPredicate.Evaluate("client.tags in [`vip`, `standard`]", customer);
- Fork the repository
- Create your feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request
This project is licensed under the MIT License
- see the license file for details.
- 📖 Read the Documentation
- 🐛 If you are having problems, please let us know by raising a new issue here.
- 💬 Ask questions on Discussions