cargo / serde_with
serde_with
What changed in serde_with 2 to 3, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-20.
15 breaking3 security9 new APIs and options5 behavior and defaults6 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initserde_with 321 changes
Breaking changes 3
The minimum supported Rust version is bumped to 1.88 due to the darling dependency.
The minimum supported Rust version is now 1.82 because yaml_serde requires it as a dev-dependency.
Support for custom character sets used for base64 was removed; predefined character sets remain available.
Security 3
These collections now use size_hint_cautious, preventing attacker-controlled huge length hints from causing a capacity-overflow panic before any elements are read.
Limits allocation size during collection creation, preventing bad or attacker-controlled values from causing a panic.
serde_with: KeyValueMap serialization panics on empty sequence or map entries
New APIs and options 7
The new feature flag enables support for jiff v0.2, including the listed jiff types with DurationSeconds and TimestampSeconds adapters.
Adds an adapter that maps
Option<NonZero*>to a plain integer, encodingNoneas0.Adds support for base58 encoding, similar to the existing base64 setup.
Extends base64 with schemars support.
Adds support for hashbrown v0.17, extending the existing version support.
Adds a JsonSchemaAs implementation for json::JsonString.
Adds support for smallvec v1 when the smallvec_1 feature flag is enabled.
Behavior and default changes 3
with_prefix! is now available with the alloc feature instead of requiring std.
with_suffix! is now available with the alloc feature instead of requiring std.
OneOrMany now supports more sequence and set types.
Fixes and other changes 5
Deserialization of chrono and time DateTimes now handles potential panics.
Fields using NoneAsEmptyString now compile with the schemars_* features through a JsonSchemaAs implementation.
serde_as can now parse cfg_attr attributes with true or false conditions, including when emitting schemars annotations.
OneOrMany now supports smallvec v1.
Fixed JsonSchemaAs for SetPreventDuplicates and SetLastValueWins.
serde_with 217 changes
Breaking changes 12
The module-based conversion is removed; use BytesOrString in serde_as instead.
The module-based conversion is removed; use DefaultOnError in serde_as instead.
The module-based conversion is removed; use DefaultOnNull in serde_as instead.
The module-based conversion is removed; use DisplayFromStr in serde_as instead.
The Separator trait and its implementations have moved to the formats module.
The module-based conversion is removed; use json::JsonString in serde_as instead.
The minimum supported Rust version is now 1.60, required for the optional dependency feature syntax in cargo.
The module-based conversion is removed; use DisplayFromStr with the container type in serde_as.
The previously deprecated module is removed.
The old module conversion is removed; use NoneAsEmptyString with serde_as instead.
StringWithSeparator can now only be used in serde_as.
The module-based conversion is removed; use BTreeMap or HashMap in serde_as on a Vec of tuples.
New APIs and options 2
JsonString can now nest serde_as definitions, allowing custom serialization logic before a value is converted into a JSON string.
Use no_default to suppress the automatic serde(default) behavior for matching Option fields.
Behavior and default changes 2
The serialization bound changes from AsRef<str> to a different bound, making serialization less limiting for non-string types like Option<i32>.
Its serialization bound changes from AsRef<str> to a different bound, making serialization less limiting for non-string types like Option<i32>.
Fixes and other changes 1
On an Option<T> field using Option<S>, the macro now applies serde(default) unless a default attribute is already present, allowing deserialization when the field is missing.