Class JsonShapeMatcher
public static class JsonShapeMatcher
- Inheritance
-
JsonShapeMatcher
- Inherited Members
Methods
AssertExactMatch(string, object?, JsonSerializerOptions?)
Matches the whole JSON exactly: every field present in the JSON must be mentioned by the expected shape, so the response cannot carry a field the shape does not declare. A value constraint mentions its whole subtree. Every mismatch - including each unmentioned field - is reported at once. Returns the matched property paths.
public static IReadOnlyList<string> AssertExactMatch(string content, object? expected, JsonSerializerOptions? options = null)
Parameters
contentstringexpectedobjectoptionsJsonSerializerOptions
Returns
AssertExactMatch(JsonElement, object?, JsonSerializerOptions?)
Matches the whole JSON exactly; see AssertExactMatch(string, object?, JsonSerializerOptions?).
public static IReadOnlyList<string> AssertExactMatch(JsonElement actual, object? expected, JsonSerializerOptions? options = null)
Parameters
actualJsonElementexpectedobjectoptionsJsonSerializerOptions
Returns
AssertMatch(string, object?, JsonSerializerOptions?)
public static IReadOnlyList<string> AssertMatch(string content, object? expected, JsonSerializerOptions? options = null)
Parameters
contentstringexpectedobjectoptionsJsonSerializerOptions
Returns
AssertMatch(JsonElement, object?, JsonSerializerOptions?)
public static IReadOnlyList<string> AssertMatch(JsonElement actual, object? expected, JsonSerializerOptions? options = null)
Parameters
actualJsonElementexpectedobjectoptionsJsonSerializerOptions
Returns
FindUnmentionedFields(string, IReadOnlyCollection<string>, JsonSerializerOptions?)
The fields of content that mentionedPaths does not cover,
in document order and one shallowest path per unmentioned branch. Property names follow the
same case rule as matching (PropertyNameCaseInsensitive,
case-insensitive by default). Empty content reports nothing; invalid JSON throws
JsonDocumentAssertionException like AssertMatch(string, object?, JsonSerializerOptions?).
public static IReadOnlyList<JsonUnmentionedField> FindUnmentionedFields(string content, IReadOnlyCollection<string> mentionedPaths, JsonSerializerOptions? options = null)
Parameters
contentstringmentionedPathsIReadOnlyCollection<string>optionsJsonSerializerOptions
Returns
FindUnmentionedFields(JsonElement, IReadOnlyCollection<string>, JsonSerializerOptions?)
The fields of actual that mentionedPaths does not cover;
see FindUnmentionedFields(string, IReadOnlyCollection<string>, JsonSerializerOptions?).
public static IReadOnlyList<JsonUnmentionedField> FindUnmentionedFields(JsonElement actual, IReadOnlyCollection<string> mentionedPaths, JsonSerializerOptions? options = null)
Parameters
actualJsonElementmentionedPathsIReadOnlyCollection<string>optionsJsonSerializerOptions