Class FrameTypesConverter
- Namespace
- Tudormobile.Strava.Converters
- Assembly
- Tudormobile.Strava.dll
Custom JSON converter for the FrameTypes enum.
public class FrameTypesConverter : JsonConverter<FrameTypes>
- Inheritance
-
FrameTypesConverter
- Inherited Members
Remarks
This converter handles serialization and deserialization of FrameTypes enum values to and from JSON. It supports both numeric (integer) and string representations of the enum values. The Strava API typically returns frame_type as a string (e.g., "Road", "Mountain").
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to a FrameTypes value. Handles both numeric and string representations of the enum.
public override FrameTypes Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader to read from.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsThe serializer options.
Returns
- FrameTypes
The deserialized FrameTypes value.
Write(Utf8JsonWriter, FrameTypes, JsonSerializerOptions)
Writes the FrameTypes value as a numeric value to JSON.
public override void Write(Utf8JsonWriter writer, FrameTypes value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueFrameTypesThe FrameTypes value to write.
optionsJsonSerializerOptionsThe serializer options.