JsonBoolConverter

Ecng.Serialization

Converts boolean values to and from JSON numeric representations (1 or 0).

Hereda de: JsonConverter

Métodos

CanConvert
public override bool CanConvert(Type objectType)
result = jsonBoolConverter.CanConvert(objectType)

Determines whether this converter can convert the specified object type.

objectType
The type of object to check.

Devuelve: true if the object type is Boolean; otherwise, false.

ReadJson
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
result = jsonBoolConverter.ReadJson(reader, objectType, existingValue, serializer)

Reads a JSON value and converts it to a boolean value where "1" represents true.

reader
The JsonReader to read from.
objectType
The type of the object to convert to.
existingValue
The existing value of the object being read.
serializer
The calling serializer.

Devuelve: A boolean value where "1" evaluates to true, and any other value to false.

WriteJson
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
jsonBoolConverter.WriteJson(writer, value, serializer)

Writes a boolean value as 1 (true) or 0 (false) to the JSON output.

writer
The JsonWriter to write to.
value
The boolean value to be converted and written.
serializer
The calling serializer.