HumanReadableSerializer Class
Serializes objects to a human-readable text format.
public static class HumanReadableSerializerExample
var obj = new { Name = "John Doe", Age = 32 };
var output = HumanReadableSerializer.Serialize(obj);
Assert.Equal("Name: John Doe\nAge: 32", output);Methods
| Name | Description |
|---|---|
| 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.csSerializes the specified value to the provided writer.
public static void Serialize(HumanReadableTextWriter writer, object? value, Type type, HumanReadableSerializerOptions options)Parameters
writerHumanReadableTextWriter- The writer to serialize to.
valueobject?- The value to serialize.
typeType- The type to use for serialization.
optionsHumanReadableSerializerOptions- Options to control the serialization behavior.
Serialize(object?, HumanReadableSerializerOptions?)
HumanReadableSerializer.csSerializes the specified value to a human-readable string.
public static string Serialize(object? value, HumanReadableSerializerOptions? options = null)Parameters
valueobject?- The value to serialize.
optionsHumanReadableSerializerOptions?- Options to control the serialization behavior.
Returns
string A human-readable string representation of the value.
Serialize(object?, Type, HumanReadableSerializerOptions?)
HumanReadableSerializer.csSerializes the specified value as the specified type to a human-readable string.
public static string Serialize(object? value, Type type, HumanReadableSerializerOptions? options = null)Parameters
valueobject?- The value to serialize.
typeType- The type to use for serialization.
optionsHumanReadableSerializerOptions?- Options to control the serialization behavior.
Returns
string A human-readable string representation of the value.
Serialize<T>(HumanReadableTextWriter, T?, HumanReadableSerializerOptions)
HumanReadableSerializer.csSerializes 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
writerHumanReadableTextWriter- The writer to serialize to.
valueT?- The value to serialize.
optionsHumanReadableSerializerOptions- Options to control the serialization behavior.