We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cf581a0 commit 70a9fddCopy full SHA for 70a9fdd
src/lib.rs
@@ -511,4 +511,14 @@ mod tests {
511
let s: S = toml::from_str(r#"x = "9223372036854775807""#).unwrap();
512
assert_eq!(s.x, "9223372036854775807".parse::<ByteSize>().unwrap());
513
}
514
+
515
+ #[test]
516
+ #[cfg(feature = "serde")]
517
+ fn test_serde_json() {
518
+ let json = serde_json::to_string(&ByteSize::mib(1)).unwrap();
519
+ assert_eq!(json, "\"1.0 MiB\"");
520
521
+ let deserialized: ByteSize = serde_json::from_str(&json).unwrap();
522
+ assert_eq!(deserialized.0, 1048576);
523
+ }
524
0 commit comments