Class JsonEquivalenceOptions
- Namespace
- JsonAssertions
- Assembly
- JsonAssertions.TUnit.dll
Options for Compare(JsonElement, JsonElement, JsonEquivalenceOptions): the JSON-path locations excluded from the comparison, and whether arrays are compared order-insensitively. Configured through the fluent IgnorePath(string) and IgnoreArrayOrder() methods inside the configure callback.
public sealed class JsonEquivalenceOptions
- Inheritance
-
JsonEquivalenceOptions
- Inherited Members
- Extension Methods
Properties
IgnoreArrayOrderEnabled
Whether arrays are compared without regard to element order. Off by default: arrays are ordered in JSON, so equality is position-sensitive unless this is enabled. When enabled, two arrays are equivalent if they have the same length and each element on one side has a distinct equivalent element on the other (multiset equality).
public bool IgnoreArrayOrderEnabled { get; }
Property Value
IgnoredPaths
The JSON paths excluded from the comparison, in registration order. Each is resolved (wildcards expanded) against both documents; a value at an ignored path contributes nothing to equivalence, whether it is present, absent, or differs. Returned as a read-only view; register paths through IgnorePath(string) so the non-empty validation is enforced.
public IReadOnlyList<string> IgnoredPaths { get; }
Property Value
Methods
IgnoreArrayOrder()
Compares arrays order-insensitively for the remainder of this comparison (see IgnoreArrayOrderEnabled).
public JsonEquivalenceOptions IgnoreArrayOrder()
Returns
- JsonEquivalenceOptions
This instance, for chaining.
IgnorePath(string)
Excludes a JSON path from the comparison. The path uses the same grammar as the
assertion paths, including the [] wildcard (so items[].timestamp ignores that
field on every array element). A path that does not resolve on either document is a no-op.
Combining a positional array-index path with IgnoreArrayOrder() is not meaningful,
since order-insensitive matching makes indices ambiguous; use the [*] wildcard to ignore
a field across all elements instead.
public JsonEquivalenceOptions IgnorePath(string path)
Parameters
pathstringThe JSON path to ignore. Must be non-empty.
Returns
- JsonEquivalenceOptions
This instance, for chaining.
Exceptions
- ArgumentException
pathis null, empty, or whitespace.