Skip to main content

deserialize

Function deserialize 

Source
pub fn deserialize<'de, D: Deserializer<'de>>(
    deserializer: D,
) -> Result<Decimal, D::Error>
Expand description

Deserializes an exact decimal from strings, integers, or arbitrary-precision number maps.

Supports direct JSON and Serde enum buffers. Integers outside the 64-bit range, fractional tokens, and scientific numeric tokens require serde_json/arbitrary_precision. Use deserialize_json for default-feature JSON or buffered Value. Some buffered Number values use Serde’s float route even with arbitrary precision; parse their text with parse instead. With arbitrary precision, accepts serde_json’s private number maps, including literal objects with the same reserved key. Use deserialize_json before buffering when the original JSON shape must be checked.

§Errors

Returns an error if:

  • The input is a float, null, an empty string, or an invalid decimal.
  • Representing the value requires rounding.