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 is handled as either a JSON number or a string representation of an integer.
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type TokenResponse.
[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.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- TokenResponse
The converted value.
Write(Utf8JsonWriter, TokenResponse?, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, TokenResponse? value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueTokenResponseThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Exceptions
- ArgumentNullException
Thrown when
writeris null.