JsonBooleanLiteralsConverter
Namespace: SnowBank.Data.Json · class
Implements: IJsonMemberConverter<bool>, IJsonPacker<bool>, IJsonDeserializer<bool>
Converter installed for members carrying JsonBooleanLiteralsAttribute; feeds the same per-member converter slot as [JsonConverter(typeof(...))]
Remarks
Public because generated converters instantiate it directly; application code normally uses the attribute instead.
Constructors
JsonBooleanLiteralsConverter
JsonBooleanLiteralsConverter(object whenFalse, object whenTrue, bool strictLiterals = false)
Specifies the output literals for this member
whenFalse— Output form offalse: aString, aBoolean, or a numeric value (ex:"0",0). Passnullto NOT EMIT the member at all when the value isfalse, for a consumer that expects either the member absent or the true literal.whenTrue— Output form oftrue: aString, aBoolean, or a numeric value (ex:"1",1). It may not benull: emitting nothing fortruehas no meaning.
The two arguments do not have to share a type: [JsonBooleanLiterals("0", 1)] is legal, because legacy outputs are not always consistent.
Methods
Pack
JsonValue Pack(ref CrystalJsonPackContext context, bool instance)
Unpack
bool Unpack(JsonValue value, ICrystalJsonTypeResolver resolver)