Table of Contents

IntervalSetJsonConverter<T> Class

Definition

Namespace
Bodu.Numerics.Serialization.Json
Assembly
Bodu.Numerics.Serialization.Json.dll
Package
Bodu.Numerics.Serialization.Json 1.0.0
Source
IntervalSetJsonConverter{T}.cs

Converts an IntervalSet<T> to and from JSON using the policy supplied at construction.

public sealed class IntervalSetJsonConverter<T> : JsonConverter<IntervalSet<T>> where T : INumber<T>

Type Parameters

T

The numeric endpoint type of the set's pieces.

Inheritance
IntervalSetJsonConverter<T>
Inherited Members
Extension Methods

Remarks

An IntervalSet<T> serializes as a JSON array of its normalized Interval<T> pieces, each written through IntervalJsonConverter<T> under the same NumericsJsonPolicy. The empty set is the empty array []; a two-piece set under Compact is, for example, ["[1, 3]", "(5, 8]"]. On read the pieces are collected and re-normalized through From(IEnumerable<Interval<T>>), so overlapping or adjacent input coalesces.

Constructors

IntervalSetJsonConverter()

Initializes a new instance of the IntervalSetJsonConverter<T> class configured for the Strict shape.

public IntervalSetJsonConverter()

IntervalSetJsonConverter(NumericsJsonPolicy)

Initializes a new instance of the IntervalSetJsonConverter<T> class configured for the supplied policy.

public IntervalSetJsonConverter(NumericsJsonPolicy policy)

Parameters

policy NumericsJsonPolicy

The serialization policy.

Exceptions

ArgumentOutOfRangeException

policy is not a defined NumericsJsonPolicy value.

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON to type Bodu.Numerics.IntervalSet{`0}.

public override IntervalSet<T> 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

IntervalSet<T>

The converted value.

Write(Utf8JsonWriter, IntervalSet<T>, JsonSerializerOptions)

Writes a specified value as JSON.

public override void Write(Utf8JsonWriter writer, IntervalSet<T> value, JsonSerializerOptions options)

Parameters

writer Utf8JsonWriter

The writer to write to.

value IntervalSet<T>

The value to convert to JSON.

options JsonSerializerOptions

An object that specifies serialization options to use.

Applies to

ProductVersions
.NET8, 10