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
objectType
TypeThe 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
reader
JsonReaderThe Newtonsoft.Json.JsonReader to read from.
objectType
TypeThe type of the object to convert to.
existingValue
objectThe existing value of the object being read.
serializer
JsonSerializerThe 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
writer
JsonWriterThe Newtonsoft.Json.JsonWriter to write to.
value
objectThe boolean value to be converted and written.
serializer
JsonSerializerThe calling serializer.