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
readerUtf8JsonReaderThe reader to read from.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsThe 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
writerUtf8JsonWriterThe writer to write to.
valueSegmentStreamCollectionThe SegmentStreamCollection value to write.
optionsJsonSerializerOptionsThe serializer options.