Table of Contents

Class PreservingNullableJsonElementConverter

Namespace
SpecWorks.AiCatalog.Models
Assembly
SpecWorks.AiCatalog.dll

Preserves the distinction between absent data and an explicit JSON null.

public sealed class PreservingNullableJsonElementConverter : JsonConverter<JsonElement?>
Inheritance
object
JsonConverter
JsonConverter<JsonElement?>
PreservingNullableJsonElementConverter

Properties

HandleNull

Gets a value that indicates whether null should be passed to the converter on serialization, and whether System.Text.Json.JsonTokenType.Null should be passed on deserialization.

public override bool HandleNull { get; }

Property Value

bool

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON to type System.Text.Json.JsonElement?.

public override JsonElement? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)

Parameters

reader Utf8JsonReader

The reader.

typeToConvert Type

The type to convert.

options JsonSerializerOptions

An object that specifies serialization options to use.

Returns

JsonElement?

The converted value.

Write(Utf8JsonWriter, JsonElement?, JsonSerializerOptions)

Writes a specified value as JSON.

public override void Write(Utf8JsonWriter writer, JsonElement? value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The writer to write to.

value JsonElement?

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.