Table of Contents

Class JsonSerializerExtensions

Namespace
Xunit.Sdk

Extension methods for the JSON serialization types.

public static class JsonSerializerExtensions
Inheritance
JsonSerializerExtensions
Inherited Members

Methods

SerializeIntArray(JsonObjectSerializer, string, IEnumerable<int>?, bool)

Serializes an array of integers into the object.

public static void SerializeIntArray(this JsonObjectSerializer serializer, string key, IEnumerable<int>? values, bool includeNullArray = false)

Parameters

serializer JsonObjectSerializer
key string

The key to serialize the array to

values IEnumerable<int>

The values in the array

includeNullArray bool

Whether to serialize the array if it's null

SerializeStringArray(JsonObjectSerializer, string, IEnumerable<string?>?, bool)

Serializes an array of strings into the object.

public static void SerializeStringArray(this JsonObjectSerializer serializer, string key, IEnumerable<string?>? values, bool includeNullArray = false)

Parameters

serializer JsonObjectSerializer
key string

The key to serialize the array to

values IEnumerable<string>

The values in the array

includeNullArray bool

Whether to serialize the array if it's null

SerializeTraits(JsonObjectSerializer, string, IReadOnlyDictionary<string, IReadOnlyCollection<string>>, bool)

Serialize a trait dictionary value into the object.

public static void SerializeTraits(this JsonObjectSerializer serializer, string key, IReadOnlyDictionary<string, IReadOnlyCollection<string>> dictionary, bool includeEmptyTraits = false)

Parameters

serializer JsonObjectSerializer
key string

The name of the value

dictionary IReadOnlyDictionary<string, IReadOnlyCollection<string>>

The trait dictionary

includeEmptyTraits bool

A flag to indicate whether to render empty traits