Ferrous API Reference

All Types / Ferrous.Results

class OptionJsonConverter<T>

public sealed class OptionJsonConverter<T> : JsonConverter<Option<T>>

NativeAOT-compatible JsonConverter<T> for Option<T>. Serializes Some(v) directly as v and None as JSON null.

Type Parameters
T
The wrapped value type.

Constructors

public OptionJsonConverter()

Initializes a new converter using the JsonSerializerOptions passed at read/write time.

public OptionJsonConverter(JsonTypeInfo<T> typeInfo)

Initializes a new NativeAOT-safe converter using an explicit JsonTypeInfo<T>.

Parameters
typeInfo
The source-generated JsonTypeInfo<T> for T.

Properties

public override bool HandleNull

Methods

public override Option<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
public override void Write(Utf8JsonWriter writer, Option<T> value, JsonSerializerOptions options)