Class NewtonsoftHttpMethodConverter
- Namespace
- Vonage.Common.Serialization
- Assembly
- Vonage.dll
Represents a custom converter from HttpMethod to Json for Newtonsoft.Json.
public class NewtonsoftHttpMethodConverter : JsonConverter<HttpMethod>
- Inheritance
-
JsonConverterJsonConverter<HttpMethod>NewtonsoftHttpMethodConverter
- Inherited Members
-
JsonConverter.CanReadJsonConverter.CanWrite
Examples
var settings = new JsonSerializerSettings();
settings.Converters.Add(new NewtonsoftHttpMethodConverter());
string json = JsonConvert.SerializeObject(HttpMethod.Get, settings);
// Produces: "GET"
Methods
ReadJson(JsonReader, Type, HttpMethod, bool, JsonSerializer)
Reads the JSON representation of the object.
public override HttpMethod ReadJson(JsonReader reader, Type objectType, HttpMethod existingValue, bool hasExistingValue, JsonSerializer serializer)
Parameters
readerJsonReaderThe Newtonsoft.Json.JsonReader to read from.
objectTypeTypeType of the object.
existingValueHttpMethodThe existing value of object being read. If there is no existing value then
nullwill be used.hasExistingValueboolThe existing value has a value.
serializerJsonSerializerThe calling serializer.
Returns
- HttpMethod
The object value.
WriteJson(JsonWriter, HttpMethod, JsonSerializer)
Writes the JSON representation of the object.
public override void WriteJson(JsonWriter writer, HttpMethod value, JsonSerializer serializer)
Parameters
writerJsonWriterThe Newtonsoft.Json.JsonWriter to write to.
valueHttpMethodThe value.
serializerJsonSerializerThe calling serializer.