By default ServiceStack's Text serializers tries to deserialize as much as possible without error. You can set JsConfig.ThrowOnError=true;
(or Env.Strict=true
in latest v5.1.1+ on MyGet) if you want the JSON Serializer to throw on deserialization error.
Or you can instead log any serialization errors to the console with:
Tracer.Instance = new ConsoleTracer();
The difference in behavior is that due to popular conventions values such as 1
, "1"
and "on"
are also treated as true
any other <2 characters are treated as false
. Any other string value tries to deserialize into a boolean, e.g. "true"
or "false"
, if it's none of these values it results in a deserialization error which by default is swallowed and the property is left unset (i.e. null
).
But I've normalized behavior in this commit so only conventional values like true
, 1
, t
, Y
, on
deserializes to true and their contra values false
, 0
, f
, N
, off
deserializes to false and all other values tries to deserialize to a boolean (i.e. True/False) and will result in a deserialization error if fails.
This change is available from v5.1.1 that's now available on MyGet.