Home JsonLogic Class
JsonLogic Class
Cancel

JsonLogic Class

Namespace: Json.Logic

Inheritance: JsonLogic 🡒 object

Provides factory methods to create operations.

Methods

Add(Rule a, params Rule[] more)

Creates a + (“add”) rule.

Declaration

1
public static Rule Add(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

A + rule.

All(Rule input, Rule rule)

Creates an all rule.

Declaration

1
public static Rule All(Rule input, Rule rule)
ParameterTypeDescription
inputRuleThe input rule.
ruleRuleThe predicate to test by.

Returns

An all rule.

And(Rule a, params Rule[] more)

Creates an and rule.

Declaration

1
public static Rule And(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

An and rule.

Apply(JsonNode rule, JsonNode context)

Applies a rule encoded into a System.Text.Json.Nodes.JsonNode to some data.

Declaration

1
public static JsonNode Apply(JsonNode rule, JsonNode context)
ParameterTypeDescription
ruleJsonNodeThe rule to apply.
contextJsonNodeThe context data.

Returns

The result.

Apply(JsonNode rule, EvaluationContext context)

Applies a nested rule encoded into a System.Text.Json.Nodes.JsonNode to a context. This is to be called from within an Json.Logic.IRule handler.

Declaration

1
public static JsonNode Apply(JsonNode rule, EvaluationContext context)
ParameterTypeDescription
ruleJsonNodeThe rule to apply.
contextEvaluationContextThe context data.

Returns

The result.

BetweenExclusive(Rule a, Rule b, Rule c)

Creates a three-argument < (“exclusive between”) rule.

Declaration

1
public static Rule BetweenExclusive(Rule a, Rule b, Rule c)
ParameterTypeDescription
aRuleThe lower limit rule.
bRuleThe rule.
cRuleThe upper limit rule.

Returns

A < rule.

BetweenInclusive(Rule a, Rule b, Rule c)

Creates a three-argument <= (“inclusive between”) rule.

Declaration

1
public static Rule BetweenInclusive(Rule a, Rule b, Rule c)
ParameterTypeDescription
aRuleThe lower limit rule.
bRuleThe second rule.
cRuleThe upper limit rule.

Returns

A <= rule.

BoolCast(Rule value)

Creates a !! (“boolean cast”) rule.

Declaration

1
public static Rule BoolCast(Rule value)
ParameterTypeDescription
valueRuleThe rule to negate.

Returns

A !! rule.

Cat(Rule a, params Rule[] more)

Creates a cat (“concatenation”) rule.

Declaration

1
public static Rule Cat(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

A cat rule.

Divide(Rule a, Rule b)

Creates a / (“divide”) rule.

Declaration

1
public static Rule Divide(Rule a, Rule b)
ParameterTypeDescription
aRuleThe first rule.
bRule 

Returns

A / rule.

Filter(Rule input, Rule rule)

Creates a filter rule.

Declaration

1
public static Rule Filter(Rule input, Rule rule)
ParameterTypeDescription
inputRuleThe input rule.
ruleRuleThe predicate to test by.

Returns

A filter rule.

If(params Rule[] components)

Creates an if rule.

Declaration

1
public static Rule If(params Rule[] components)
ParameterTypeDescription
componentsparams Rule[]The rule chain to process.

Returns

An if rule.

In(Rule test, Rule input)

Creates a none rule.

Declaration

1
public static Rule In(Rule test, Rule input)
ParameterTypeDescription
testRuleThe predicate to test by.
inputRuleThe input rule.

Returns

A none rule.

LessThan(Rule a, Rule b)

Creates a < (“less than”) rule.

Declaration

1
public static Rule LessThan(Rule a, Rule b)
ParameterTypeDescription
aRuleThe lower limit rule.
bRuleThe upper limit rule.

Returns

A < rule.

LessThanOrEqual(Rule a, Rule b)

Creates a <= (“less than or equal”) rule.

Declaration

1
public static Rule LessThanOrEqual(Rule a, Rule b)
ParameterTypeDescription
aRuleThe lower limit rule.
bRuleThe upper limit rule.

Returns

A <= rule.

Literal(JsonNode value)

Creates a rule that stands in for a literal JSON value.

Declaration

1
public static Rule Literal(JsonNode value)
ParameterTypeDescription
valueJsonNodeThe JSON value.

Returns

A literal rule.

Log(Rule log)

Functions as a no-op. Processes the rule, then logs and returns the output.

Declaration

1
public static Rule Log(Rule log)
ParameterTypeDescription
logRuleThe rule to log.

Returns

The result of the rule.

LooseEquals(Rule a, Rule b)

Creates a == (“loose equal”) rule.

Declaration

1
public static Rule LooseEquals(Rule a, Rule b)
ParameterTypeDescription
aRuleThe first rule.
bRuleThe second rule.

Returns

A == rule.

LooseNotEquals(Rule a, Rule b)

Creates a != (“loose not equal”) rule.

Declaration

1
public static Rule LooseNotEquals(Rule a, Rule b)
ParameterTypeDescription
aRuleThe first rule.
bRuleThe second rule.

Returns

A != rule.

Map(Rule input, Rule rule)

Creates a map rule.

Declaration

1
public static Rule Map(Rule input, Rule rule)
ParameterTypeDescription
inputRuleThe input rule.
ruleRuleThe predicate to test by.

Returns

A map rule.

Max(Rule a, params Rule[] more)

Creates a max rule.

Declaration

1
public static Rule Max(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

A max rule.

Merge(params Rule[] items)

Creates a merge rule.

Declaration

1
public static Rule Merge(params Rule[] items)
ParameterTypeDescription
itemsparams Rule[]The items to merge.

Returns

A merge rule.

Min(Rule a, params Rule[] more)

Creates a min rule.

Declaration

1
public static Rule Min(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

A min rule.

Missing(params Rule[] components)

Creates a missing rule.

Declaration

1
public static Rule Missing(params Rule[] components)
ParameterTypeDescription
componentsparams Rule[]The missing components.

Returns

A missing rule.

MissingSome(Rule requiredCount, Rule components)

Creates a missing-some rule.

Declaration

1
public static Rule MissingSome(Rule requiredCount, Rule components)
ParameterTypeDescription
requiredCountRuleThe required count.
componentsRuleThe missing components.

Returns

A missing_some rule.

Modulus(Rule a, Rule b)

Creates a % (“modulus”) rule.

Declaration

1
public static Rule Modulus(Rule a, Rule b)
ParameterTypeDescription
aRuleThe first rule.
bRule 

Returns

A % rule.

MoreThan(Rule a, Rule b)

Creates a > (“more than”) rule.

Declaration

1
public static Rule MoreThan(Rule a, Rule b)
ParameterTypeDescription
aRuleThe upper limit rule.
bRuleThe lower limit rule.

Returns

A > rule.

MoreThanOrEqual(Rule a, Rule b)

Creates a >= (“more than or equal”) rule.

Declaration

1
public static Rule MoreThanOrEqual(Rule a, Rule b)
ParameterTypeDescription
aRuleThe upper limit rule.
bRuleThe lower limit rule.

Returns

A > rule.

Multiply(Rule a, params Rule[] more)

Creates a * (“multiply”) rule.

Declaration

1
public static Rule Multiply(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

A * rule.

None(Rule input, Rule rule)

Creates a none rule.

Declaration

1
public static Rule None(Rule input, Rule rule)
ParameterTypeDescription
inputRuleThe input rule.
ruleRuleThe predicate to test by.

Returns

A none rule.

Not(Rule value)

Creates a ! (“not”) rule.

Declaration

1
public static Rule Not(Rule value)
ParameterTypeDescription
valueRuleThe rule to negate.

Returns

A ! rule.

Or(Rule a, params Rule[] more)

Creates an or rule.

Declaration

1
public static Rule Or(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

An or rule.

Reduce(Rule input, Rule rule, Rule initial)

Creates a reduce rule.

Declaration

1
public static Rule Reduce(Rule input, Rule rule, Rule initial)
ParameterTypeDescription
inputRuleThe input rule.
ruleRuleThe predicate to test by.
initialRuleThe initial rule.

Returns

A reduce rule.

Some(Rule input, Rule rule)

Creates a some (“any”) rule.

Declaration

1
public static Rule Some(Rule input, Rule rule)
ParameterTypeDescription
inputRuleThe input rule.
ruleRuleThe predicate to test by.

Returns

A some rule.

StrictEquals(Rule a, Rule b)

Creates a === (“strict equal”) rule.

Declaration

1
public static Rule StrictEquals(Rule a, Rule b)
ParameterTypeDescription
aRuleThe first rule.
bRuleThe second rule.

Returns

A === rule.

StrictNotEquals(Rule a, Rule b)

Creates a !== (“strict not equal”) rule.

Declaration

1
public static Rule StrictNotEquals(Rule a, Rule b)
ParameterTypeDescription
aRuleThe first rule.
bRuleThe second rule.

Returns

A !== rule.

Substr(Rule input, Rule start)

Creates a substr (“concatenation”) rule.

Declaration

1
public static Rule Substr(Rule input, Rule start)
ParameterTypeDescription
inputRuleThe input rule.
startRuleThe start rule.

Returns

A substr rule.

Substr(Rule input, Rule start, Rule count)

Creates a substr (“concatenation”) rule.

Declaration

1
public static Rule Substr(Rule input, Rule start, Rule count)
ParameterTypeDescription
inputRuleThe input rule.
startRuleThe start rule.
countRuleThe count rule.

Returns

A substr rule.

Subtract(Rule a, params Rule[] more)

Creates a - (“subtract”) rule.

Declaration

1
public static Rule Subtract(Rule a, params Rule[] more)
ParameterTypeDescription
aRuleThe first rule.
moreparams Rule[]Subsequent rules.

Returns

A - rule.

Variable(string path)

Creates a var rule that accesses data.

Declaration

1
public static Rule Variable(string path)
ParameterTypeDescription
pathstring 

Returns

A variable rule.

Variable(string path, Rule defaultValue)

Creates a var rule that accesses data.

Declaration

1
public static Rule Variable(string path, Rule defaultValue)
ParameterTypeDescription
pathstringThe dot-delimited path.
defaultValueRuleA default value to use if the path is not found.

Returns

A variable rule.

Contents