Skip to main content

deserialize_decimal_native

Function deserialize_decimal_native 

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

Deserializes a Decimal through rust_decimal’s own Deserialize implementation, keeping its rounding and scale.

When rust_decimal’s arbitrary-precision integration is disabled, serde_json arbitrary-precision numbers parse from their text as rust_decimal parses a string, which matches the result with that integration enabled. Unlike deserialize_decimal, null and empty strings are errors.

§Errors

Returns an error if:

  • The value is null or an empty string.
  • The value is a non-numeric type.
  • rust_decimal rejects the value.