Table of Contents

Class SegmentStreamCollectionConverter

Namespace
Tudormobile.Strava.Converters
Assembly
Tudormobile.Strava.dll

Converts SegmentStreamCollection objects to and from JSON using custom serialization logic.

public class SegmentStreamCollectionConverter : JsonConverter<SegmentStreamCollection>
Inheritance
SegmentStreamCollectionConverter
Inherited Members

Remarks

This converter enables serialization and deserialization of SegmentStreamCollection instances when working with System.Text.Json. It inspects the "type" property of each stream object in the JSON array to determine whether to deserialize as a SegmentStream (when "type" is "latlng") or as a SegmentEffortStream. Register this converter with a JsonSerializerOptions instance to ensure correct handling of SegmentStreamCollection types during JSON operations.

Methods

Read(ref Utf8JsonReader, Type, JsonSerializerOptions)

Reads and converts the JSON array to a SegmentStreamCollection instance.

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

Parameters

reader Utf8JsonReader

The reader to read from.

typeToConvert Type

The type to convert.

options JsonSerializerOptions

The serializer options.

Returns

SegmentStreamCollection

The deserialized SegmentStreamCollection.

Exceptions

JsonException

Thrown if the JSON is not in the expected format.

Write(Utf8JsonWriter, SegmentStreamCollection, JsonSerializerOptions)

Writes a SegmentStreamCollection instance to JSON.

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

Parameters

writer Utf8JsonWriter

The writer to write to.

value SegmentStreamCollection

The SegmentStreamCollection value to write.

options JsonSerializerOptions

The serializer options.