.Net library to provide a powerful and intuitive way to evaluate 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 - Array Handling: Evaluate conditions on
arrays
andcollections
. Support arrayindexing
(Available from v1.1.0) - String Operations:
starts_with
,ends_with
,contains
(Available from v1.2.0) - Type Safety:
Automatic
type conversion and validation - Complex Expressions:
Parentheses
grouping andnested
operations - Lightweight:
Minimal
dependencies,fast
evaluation - Thread-Safe: Safe for use in
multi-threaded
environments - Performance Optimized: Efficient parsing and evaluation for
high-performance
scenarios
Install via NuGet Package Manager:
NuGet\Install-Package JsonPredicate
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.
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
- String Operators -
starts_with
,ends_with
,contains
(Available from v1.2.0)
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);
bool
bool result4 = JSONPredicate.Evaluate("client.address.postcode starts_with `e11`", customer);
bool result5 = JSONPredicate.Evaluate("client.address.postcode ends_with `3et`", customer);
bool result6 = JSONPredicate.Evaluate("client.address.postcode contains `13`", customer);
bool result7 = JSONPredicate.Evaluate("client.tags[1] eq `premium`", customer);
Please see Developer Guide for comprehensive documentation to integrate JSONPredicate in your project.
This section provides the summary of planned releases with key details about each release.
Version | Release Date | Type | Key Improvements | Backward Compatible |
---|---|---|---|---|
v1.0.0 | August 2025 | Major | Initial release with core predicate evaluation | N/A |
v1.2.0 | October 2025 | Minor | Namespace consistency, thread safety, 50%+ performance improvement, array indexing, new operators (starts_with , ends_with , contains ), comprehensive unit tests |
Yes |
v2.0.0 | TBC | Major | Comprehensive validation, performance benchmarking, thread safety verification, complete documentation | Mostly* |
*Note: v2.0.0 marked as "Mostly" backward compatible due to major internal changes that may affect some advanced usage patterns.
Please see Release Roadmap for more details.
This project is licensed under the MIT License
- see the license file for details.
We welcome contributions! Please see our Contributing Guide for details.
- ๐ Read the Documentation
- ๐ If you are having problems, please let us know by raising a new issue here.
- ๐ฌ Ask questions on Discussions
- ๐ป Code - Submit pull requests
Thank you for reading. Please fork, explore, contribute and report. Happy Coding !! :)