Class JsonDiagnosticSanitizer

Namespace
ProtoTest.Json
Assembly
ProtoTest.Json.dll

Turns a captured body into evidence that is safe to keep and readable in the viewer.

public static class JsonDiagnosticSanitizer
Inheritance
JsonDiagnosticSanitizer
Inherited Members

Methods

LooksLikeJson(string?)

Whether the content starts with a JSON object or array, ignoring leading whitespace.

public static bool LooksLikeJson(string? content)

Parameters

content string

Returns

bool

Sanitize(string, JsonDiagnosticOptions?, bool)

Redacts sensitive properties in a captured body and truncates it to the configured length. A body that is not JSON is scanned as form, multipart or XML content instead.

public static string Sanitize(string content, JsonDiagnosticOptions? configured = null, bool truncate = true)

Parameters

content string
configured JsonDiagnosticOptions
truncate bool

Returns

string

Serialize(object?, JsonDiagnosticOptions?)

Renders a value as JSON and sanitizes it. A value that cannot be serialized as a whole degrades element by element, so one unserializable item does not cost the rest.

public static string Serialize(object? value, JsonDiagnosticOptions? configured = null)

Parameters

value object
configured JsonDiagnosticOptions

Returns

string