Table of Contents

Class JsonCanonicalizeOptions

Namespace
JsonAssertions
Assembly
JsonAssertions.TUnit.dll

Options for Canonicalize(string, Action<JsonCanonicalizeOptions>?): the JSON-path locations whose values are replaced with a stable token before the document is re-serialized, and the token text itself. Configured through the fluent ScrubPath(string) and WithScrubToken(string) methods inside the configure callback.

public sealed class JsonCanonicalizeOptions
Inheritance
JsonCanonicalizeOptions
Inherited Members
Extension Methods

Properties

ScrubPaths

The JSON paths registered for scrubbing, in registration order. Each is resolved (wildcards expanded) against the document; every value it targets is replaced with ScrubToken. Returned as a read-only view; register paths through ScrubPath(string) so the non-empty validation is enforced.

public IReadOnlyList<string> ScrubPaths { get; }

Property Value

IReadOnlyList<string>

ScrubToken

The token a scrubbed value is replaced with. Defaults to "<scrubbed>".

public string ScrubToken { get; }

Property Value

string

Methods

ScrubPath(string)

Registers a JSON path whose value is replaced with ScrubToken in the canonical output. The path uses the same grammar as the assertion paths, including the [] wildcard (so [].session.connectionId scrubs that field on every array element). A path that does not resolve is a no-op.

public JsonCanonicalizeOptions ScrubPath(string path)

Parameters

path string

The JSON path to scrub. Must be non-empty.

Returns

JsonCanonicalizeOptions

This instance, for chaining.

Exceptions

ArgumentException

path is null, empty, or whitespace.

WithScrubToken(string)

Overrides the token a scrubbed value is replaced with (default "<scrubbed>").

public JsonCanonicalizeOptions WithScrubToken(string token)

Parameters

token string

The replacement token.

Returns

JsonCanonicalizeOptions

This instance, for chaining.

Exceptions

ArgumentNullException

token is null.