Class HttpMethodJsonConverter
- Namespace
- Vonage.Common.Serialization
- Assembly
- Vonage.dll
Represents a custom converter from HttpMethod to Json for System.Text.Json.
public class HttpMethodJsonConverter : JsonConverter<HttpMethod>
- Inheritance
-
HttpMethodJsonConverter
- Inherited Members
Examples
var options = new JsonSerializerOptions();
options.Converters.Add(new HttpMethodJsonConverter());
string json = JsonSerializer.Serialize(HttpMethod.Post, options);
// Produces: "POST"
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts the JSON to type HttpMethod.
public override HttpMethod Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReaderThe reader.
typeToConvertTypeThe type to convert.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.
Returns
- HttpMethod
The converted value.
Write(Utf8JsonWriter, HttpMethod, JsonSerializerOptions)
Writes a specified value as JSON.
public override void Write(Utf8JsonWriter writer, HttpMethod value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWriterThe writer to write to.
valueHttpMethodThe value to convert to JSON.
optionsJsonSerializerOptionsAn object that specifies serialization options to use.