Table of Contents

Class ComponentPropertyConverter

Namespace
Tudormobile.IronLedgerLib.Serialization
Assembly
Tudormobile.IronLedgerLib.dll

Custom JSON converter that serializes ComponentProperty lists as key-value dictionaries instead of objects with "name" and "value" properties.

public class ComponentPropertyConverter : JsonConverter<IReadOnlyList<ComponentProperty>>
Inheritance
ComponentPropertyConverter
Inherited Members

Constructors

ComponentPropertyConverter()

public ComponentPropertyConverter()

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads a JSON object and converts it into a read-only list of component properties.

public override IReadOnlyList<ComponentProperty>? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The reader positioned at the JSON to deserialize. The reader is advanced as the method processes the input.

typeToConvert Type

The type of object to convert. This parameter is provided by the serialization infrastructure and is not used directly.

options JsonSerializerOptions

The serialization options to use when reading the JSON. This parameter is provided by the serialization infrastructure and is not used directly.

Returns

IReadOnlyList<ComponentProperty>

A read-only list of component properties deserialized from the JSON object, or null if the JSON token is null.

Exceptions

JsonException

Thrown if the JSON does not start with an object, contains unexpected tokens, or ends unexpectedly.

Write(Utf8JsonWriter, IReadOnlyList<ComponentProperty>, JsonSerializerOptions)

Writes a collection of component properties to JSON using snake_case property names.

public override void Write(Utf8JsonWriter writer, IReadOnlyList<ComponentProperty> value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The writer to which the JSON output is written. Must not be null.

value IReadOnlyList<ComponentProperty>

The collection of component properties to serialize. Each property's name is converted to snake_case in the output.

options JsonSerializerOptions

Options to control the behavior of the JSON serialization. Can be used to customize serialization settings.

Remarks

Each property in the collection is written as a JSON string property with its name converted to snake_case. The method writes a single JSON object containing all properties.