Table of Contents

Class NewtonsoftJsonFacts

Namespace
RuleWright.Json.NewtonsoftJson
Assembly
RuleWright.Json.NewtonsoftJson.dll

Helpers for using Newtonsoft.Json payloads as dynamic facts: converts a Newtonsoft.Json.Linq.JToken object into the IDictionary<string, object> shape the engine's interpreter evaluates (reported as Interpreted). Uses the same number policy as the System.Text.Json adapter, so a JSON payload produces the same fact through either library.

public static class NewtonsoftJsonFacts
Inheritance
NewtonsoftJsonFacts
Inherited Members

Methods

ToDictionary(JToken)

Recursively converts a JSON object into a dictionary fact. Nested objects become nested dictionaries; arrays become object?[]; numbers become long when integral, otherwise decimal when exactly representable, otherwise double. Keys match exactly (ordinal, case-sensitive); to match field paths without regard to case, use ToDictionary(JToken, IEqualityComparer<string>).

ToDictionary(JToken, IEqualityComparer<string>)

Recursively converts a JSON object into a dictionary fact whose keys, at every level, compare with keyComparer. The interpreter looks each field-path segment up through the dictionary's own comparer, so with OrdinalIgnoreCase a rule reading Order.Total finds a camelCase payload's order.total, just as a typed fact's members already match. Values convert exactly as in ToDictionary(JToken).