pub fn as_bool<'de, D>(deserializer: D) -> Result<bool, D::Error>where
D: Deserializer<'de>,
Expand description

De-serialize either a null, bool, str, u64, or f64 as a boolean value.

Truthy String Values

Note: the pattern matching is case insensitive, so YES or yes works just the same.

These are the following “truthy” string values that result in a boolean value of true:

  • 1
  • OK
  • ON
  • T
  • TRUE
  • Y
  • YES

Errors

Returns an error if an unsigned u64 or a float f64 value is not a zero or a one.

Returns

The boolean (bool) value of a string or number.