JsonLogic built on the System.Text.Json namespace
$ dotnet add package JsonLogicJsonLogic implements the JSON Logic format, a declarative, data-driven way to define rules.
var rule = JsonNode.Parse(
"""
{
"and": [
{ "<": [{ "var": "temp" }, 110 ]},
{ "==": [{ "var": "pie.filling" }, "apple" ]}
]
}
"""
);
var data = JsonNode.Parse(
"""
{
"temp" : 100,
"pie" : { "filling" : "apple" }
}
"""
);
var result = JsonLogic.Apply(rule, data);
// result: true
If you found this library helpful and would like to promote continued development, please consider sponsoring the maintainers.