IntervalSetJsonConverter<T> Class
Definition
- Assembly
- Bodu.Numerics.Serialization.Json.dll
- Package
- Bodu.Numerics.Serialization.Json 1.0.0
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
TThe 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
policyNumericsJsonPolicyThe serialization policy.
Exceptions
- ArgumentOutOfRangeException
policyis 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
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn 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
writerUtf8JsonWriterThe writer to write to.
valueIntervalSet<T>The value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |