serde_with v1.12.0
·
685 commits
to master
since this release
Added
-
Deserialize a
Vec
and skip all elements failing to deserialize #383VecSkipError
acts like aVec
, but elements which fail to deserialize, like the"Yellow"
are ignored.#[derive(serde::Deserialize)] enum Color { Red, Green, Blue, } // JSON "colors": ["Blue", "Yellow", "Green"], // Rust #[serde_as(as = "VecSkipError<_>")] colors: Vec<Color>, // => vec![Blue, Green]
Thanks to @hdhoang for creating the PR.
-
Transform between maps and
Vec<Enum>
#375The new
EnumMap
type convertsVec
of enums into a single map.
The key is the enum variant name, and the value is the variant value.// Rust VecEnumValues(vec![ EnumValue::Int(123), EnumValue::String("Foo".to_string()), EnumValue::Unit, EnumValue::Tuple(1, "Bar".to_string()), EnumValue::Struct { a: 666, b: "Baz".to_string(), }, ] // JSON { "Int": 123, "String": "Foo", "Unit": null, "Tuple": [ 1, "Bar", ], "Struct": { "a": 666, "b": "Baz", } }
Changed
- The
Timestamp*Seconds
andTimestamp*SecondsWithFrac
types can now be used withchrono::NaiveDateTime
. #389