Class JsonBoolConverter
- Namespace
- Ecng.Serialization
- Assembly
- Ecng.Serialization.dll
Converts boolean values to and from JSON numeric representations (1 or 0).
public class JsonBoolConverter : JsonConverter
- Inheritance
-
JsonBoolConverter
- Extension Methods
Constructors
JsonBoolConverter()
public JsonBoolConverter()
Methods
CanConvert(Type)
Determines whether this converter can convert the specified object type.
public override bool CanConvert(Type objectType)
Parameters
objectTypeTypeThe type of object to check.
Returns
ReadJson(JsonReader, Type, object, JsonSerializer)
Reads a JSON value and converts it to a boolean value where "1" represents true.
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Parameters
readerJsonReaderThe Newtonsoft.Json.JsonReader to read from.
objectTypeTypeThe type of the object to convert to.
existingValueobjectThe existing value of the object being read.
serializerJsonSerializerThe calling serializer.
Returns
- object
A boolean value where "1" evaluates to true, and any other value to false.
WriteJson(JsonWriter, object, JsonSerializer)
Writes a boolean value as 1 (true) or 0 (false) to the JSON output.
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
Parameters
writerJsonWriterThe Newtonsoft.Json.JsonWriter to write to.
valueobjectThe boolean value to be converted and written.
serializerJsonSerializerThe calling serializer.