Class TokenResponseConverter
- Namespace
- Visus.AddressValidation.Serialization.Json
- Assembly
- Visus.AddressValidation.dll
Converts a TokenResponse object to and from JSON.
public sealed class TokenResponseConverter : JsonConverter<TokenResponse>
- Inheritance
-
TokenResponseConverter
- Inherited Members
Remarks
This converter handles both snake_case JSON property names (e.g. access_token) and
PascalCase property names (e.g. AccessToken). The ExpiresIn
field accepts either a JSON number or a numeric string.
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts JSON into a TokenResponse object.
[SuppressMessage("Design", "MA0051:Method is too long", Justification = "Necessary to properly handle all properties in a single pass through the JSON data.")]
public override TokenResponse Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader to read JSON from.
typeToConvertTypeThe type to convert. Must be TokenResponse.
optionsJsonSerializerOptionsThe serializer options to use during deserialization.
Returns
- TokenResponse
A TokenResponse populated from the JSON data.
Write(Utf8JsonWriter, TokenResponse?, JsonSerializerOptions)
Writes a TokenResponse object as JSON.
public override void Write(Utf8JsonWriter writer, TokenResponse? value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write JSON to.
valueTokenResponseThe TokenResponse value to serialize. May be null.
optionsJsonSerializerOptionsThe serializer options to use during serialization.
Exceptions
- ArgumentNullException
Thrown when
writeris null.