HumanReadableSerializer Class

Serializes objects to a human-readable text format.

public static class HumanReadableSerializer

Example

var obj = new { Name = "John Doe", Age = 32 };
var output = HumanReadableSerializer.Serialize(obj);
Assert.Equal("Name: John Doe\nAge: 32", output);

Methods

NameDescription
Serialize(HumanReadableTextWriter, object?, Type, HumanReadableSerializerOptions)Serializes the specified value to the provided writer.
Serialize(object?, HumanReadableSerializerOptions?)Serializes the specified value to a human-readable string.
Serialize(object?, Type, HumanReadableSerializerOptions?)Serializes the specified value as the specified type to a human-readable string.
Serialize<T>(HumanReadableTextWriter, T?, HumanReadableSerializerOptions)Serializes the specified value to the provided writer.

Serialize overloads

Serialize(HumanReadableTextWriter, object?, Type, HumanReadableSerializerOptions)

HumanReadableSerializer.cs

Serializes the specified value to the provided writer.

public static void Serialize(HumanReadableTextWriter writer, object? value, Type type, HumanReadableSerializerOptions options)
Parameters
writer HumanReadableTextWriter
The writer to serialize to.
value object?
The value to serialize.
type Type
The type to use for serialization.
options HumanReadableSerializerOptions
Options to control the serialization behavior.

Serialize(object?, HumanReadableSerializerOptions?)

HumanReadableSerializer.cs

Serializes the specified value to a human-readable string.

public static string Serialize(object? value, HumanReadableSerializerOptions? options = null)
Parameters
value object?
The value to serialize.
options HumanReadableSerializerOptions?
Options to control the serialization behavior.
Returns

string A human-readable string representation of the value.

Serialize(object?, Type, HumanReadableSerializerOptions?)

HumanReadableSerializer.cs

Serializes the specified value as the specified type to a human-readable string.

public static string Serialize(object? value, Type type, HumanReadableSerializerOptions? options = null)
Parameters
value object?
The value to serialize.
type Type
The type to use for serialization.
options HumanReadableSerializerOptions?
Options to control the serialization behavior.
Returns

string A human-readable string representation of the value.

Serialize<T>(HumanReadableTextWriter, T?, HumanReadableSerializerOptions)

HumanReadableSerializer.cs

Serializes the specified value to the provided writer.

public static void Serialize<T>(HumanReadableTextWriter writer, T? value, HumanReadableSerializerOptions options)
Type parameters
T
The type of the value to serialize.
Parameters
writer HumanReadableTextWriter
The writer to serialize to.
value T?
The value to serialize.
options HumanReadableSerializerOptions
Options to control the serialization behavior.