Module rust_decimal::serde::arbitrary_precision
source · Available on crate feature
serde
and (crate features serde-with-str
or serde-with-float
or serde-with-arbitrary-precision
) and crate feature serde-with-arbitrary-precision
only.Expand description
Serialize/deserialize Decimals as arbitrary precision numbers in JSON using the arbitrary_precision
feature within serde_json
.
#[derive(Serialize, Deserialize)]
pub struct ArbitraryExample {
#[serde(with = "rust_decimal::serde::arbitrary_precision")]
value: Decimal,
}
let value = ArbitraryExample { value: Decimal::from_str("123.400").unwrap() };
assert_eq!(
&serde_json::to_string(&value).unwrap(),
r#"{"value":123.400}"#
);