NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io, #23 most downloaded on crates.io
Macros 1.1 implementation of #[derive(Serialize, Deserialize)]
Latest stable
1.0.229
Last release 4 months ago
18 Jul 2026
Ships unpredictably
gaps range from 2 weeks to 10 months
Nearly every release is documented
notes for 56 of the last 60 stable releases
1 version withdrawn
withdrawn after publishing
10 years old
271 releases · first in 2016
Drag across the ruler to compare, or tap a release to open it.
Detect unsupported use of Deserialize on a dynamically sized struct ending in slice field
Add serialize and deserialize impls for `std::Weak and `std::Weak
std::rc::Weak and std::sync::Weak (#1251)Fix Serialize impl of an adjacently tagged empty tuple variant or struct variant
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Support flatten attribute inside of enums
flatten attribute inside of enums (#1206)Support deserializing a flattened internally tagged enum
Fix dead code warnings when generating remote impls
Respect deserialize_with used together with flatten
deserialize_with used together with flatten (#1240)Fix handling of newtype struct inside of an untagged enum in serde_test
Optimizations for binary size (#1227, #1228, #1229)
Allow integers in an internally tagged enum to be deserialized from CBOR integers of any size
More flexible deserialization of byte arrays inside of untagged and internally tagged enums (#1217, #1216)
Implement deserializer hints in handling of untagged and adjacently tagged enums to improve compile time and executable size
Infer trait bounds for use of a type parameter associated type (#1213, thanks @Osspial)
Better error messages for unsupported uses of serde(flatten) (#1204 and #1205, thanks @mitsuhiko)
serde(flatten) (#1204 and #1205, thanks @mitsuhiko)Emit working code in the case of remote = "Self" attribute
remote = "Self" attribute (#1196)Implement Serialize and Deserialize for unsigned std::NonZero* types (#1191, tracking issue https://github.com/rust-lang/rust/issues/49137, thanks @Si
Add a flatten attribute to remove one level of structure between the serialized representation and the Rust data structure; more details in struct fla
flatten attribute to remove one level of structure between the serialized representation and the Rust data structure; more details in struct flattening (#1179, thanks @mitsuhiko)Fix parsing of Self-qualified paths like "<[_]>::serialize" within serialize_with attributes
Self-qualified paths like "<[_]>::serialize" within serialize_with attributesFix derive expansion for structs containing &str or &[u8] with missing lifetime parameter
&str or &[u8] with missing lifetime parameter (#1176)Nothing published for this version
Fix borrowed Cow<[u8]> deserializing from non-UTF8 bytes (#1175, thanks @daboross)
Cow<[u8]> deserializing from non-UTF8 bytes (#1175, thanks @daboross)Fix unused parentheses warning in generated code
Update to Syn 0.12 which allows serde_derive to handle new Rust syntax that has been added within the past year
Add "UPPERCASE" option to #[serde(rename_all = "...")] (#1132, thanks @Lireer)
"UPPERCASE" option to #[serde(rename_all = "...")] (#1132, thanks @Lireer)Extend Serialize and Deserialize impls on `PhantomData` to work for T: ?Sized
PhantomData to work for T: ?SizedAdd the following function with default implementation to the Deserialize trait (thanks @Gankro!)
Add the following function with default implementation to the Deserialize trait (thanks @Gankro!)
fn deserialize_in_place<D>(deserializer: D, place: &mut Self) -> Result<(), D::Error>
where
D: Deserializer<'de>,
{
*place = Deserialize::deserialize(deserializer)?;
Ok(())
}
This is a power user feature that allows deserialization to reuse existing allocations for types like String and Vec. Enable the deserialize_in_place feature of serde_derive to generate these efficient implementations for all types that use #[derive(Deserialize)].
extern crate serde;
extern crate serde_json;
use serde::Deserialize;
fn main() {
let mut v = Vec::<i32>::with_capacity(128);
assert_eq!(v.capacity(), 128);
let j = "[1, 2, 3]";
let ref mut de = serde_json::Deserializer::from_str(j);
Deserialize::deserialize_in_place(de, &mut v).unwrap();
assert_eq!(v, [1, 2, 3]);
assert_eq!(v.capacity(), 128);
}
Fix delegation of a skipped field's default value to the container's Default impl (#1105, thanks @Binero)
Revert a change that caused serde_test deserialization tests using skipped fields to fail
Fix #[derive(Deserialize)] used with #![no_implicit_prelude]
#[derive(Deserialize)] used with #![no_implicit_prelude] (#1103)Fix deserialization of untagged newtype variant containing externally tagged struct variant in formats that represent struct variants as a sequence (#
Print the contents of the expected token when a serialize assert fails (#1086, thanks @Marwes)
Allow borrow attribute on newtype variants
borrow attribute on newtype variants (#929)Fix handling of borrowed lifetimes in fields that are skipped during deserialization (#1078, thanks @epage)
Add impls for `std::Wrapping (#1072, thanks @LinearZoetrope)
std::num::Wrapping (#1072, thanks @LinearZoetrope)Add `Serializer::is_human_readable` and `Deserializer::is_human_readable` which allow types like IpAddr to serialize in a human-readable representatio
Serializer::is_human_readable and Deserializer::is_human_readable which allow types like IpAddr to serialize in a human-readable representation in formats like JSON but in a compact binary representation in formats like Bincode (#1044, thanks @Marwes)Support for deserializing internally tagged enums in MessagePack
Generate code without warnings when a struct contains a &'static field
deny(trivial_numeric_casts) (#1053)Allow the tag of a field or enum variant to be deserialized from any unsigned integer type (#963, thanks @sfackler)
serialize_with and deserialize_with applied to entire enum variants (#1015, thanks @spinda)skip_field method so serializers can be notified when a field is skipped (#1022, thanks @sfackler)rename_all attribute (#1043, thanks @greyblake)Implement Serialize for Rc\ and Arc\ where T: ?Sized
Make remote derive usable from outside of the module containing the remote definition
NonZero deserialization to account for constructor changes in nightly (#1003)Implement Serialize and Deserialize for `std::SystemTime (#949, thanks @WiSaGaN)
std::time::SystemTime (#949, thanks @WiSaGaN)Fix inferred Deserialize bounds in remote derive
collections and alloc features to align with https://github.com/rust-lang/rust/pull/42648Add a #[serde(skip)] field attribute which unifies skip_serializing and skip_deserializing (#935, thanks @spikefoo)
#[serde(skip)] field attribute which unifies skip_serializing and skip_deserializing (#935, thanks @spikefoo)Add `BorrowedStrDeserializer` and `BorrowedBytesDeserializer` which act like IntoDeserializer implementations for &'de str and &'de [u8] (#940, thanks
BorrowedStrDeserializer and BorrowedBytesDeserializer which act like IntoDeserializer implementations for &'de str and &'de [u8] (#940, thanks @BurntSushi)~Add a #[serde(skip)] field attribute which unifies skip_serializing and skip_deserializing (#935, thanks @spikefoo)~ *(mistakenly omitted from 1.0.6,
#[serde(skip)] field attribute which unifies skip_serializing and skip_deserializing (#935, thanks @spikefoo)~ (mistakenly omitted from 1.0.6, this feature is in 1.0.8)Fix a regression in deserializing internally tagged struct variants containing unit variant containing borrowed strings
Support borrowing within internally tagged enum
Implement Deserialize for &std::Path (#924, thanks @pshc)
&std::path::Path (#924, thanks @pshc)Make adjacently tagged enums honor deny_unknown_fields (#905, thanks @TedDriggs)
Remove usage of unstable core::Zero, which was removed upstream (#898, thanks @SimonSapin)
For the first time, none of them involve further breaking changes.
<p align="center"><b>[<a href="https://serde.rs/">Serde website</a>] [<a href="https://docs.serde.rs/serde/">API documentation</a>]</b><p>
The primary focus of this release is on polish: making Serde easier to learn and more enjoyable to use. That said, this wouldn't be Serde without some amazing new features to tell you about as well.
In celebration of this milestone, I would like to highlight some of the work that has contributed toward making Serde the powerful, efficient, adaptable, convenient beast that exists today. This is the unfinished history of serialization in Rust.
rustc_serialize today.rustc_serialize crate.Thank you to more than 100 people who have contributed improvements, opened issues, provided help to others, or expressed their frustrations with Serde in a constructive way. We appreciate your continued support.
<a id="zero-copy"></a>
Serde 1.0 adds the ability to deserialize into types that borrow from the input data. For example, this JSON document can now be deserialized efficiently and safely into the following Rust struct.
{
"fingerprint": "0xF9BA143B95FF6D82",
"location": "Menlo Park, CA"
}
#[derive(Deserialize)]
struct User<'a> {
fingerprint: &'a str,
location: &'a str,
}
The value for each field will be a string slice that refers to the correct substring of the input data. No memory is allocated for the strings and no data is copied. The same thing also works for &[u8] slices. Other types can be borrowed explicitly by using the #[serde(borrow)] attribute.
This uniquely Rust-y feature would be impossible or recklessly unsafe in languages other than Rust. The semantics of Rust guarantee that the input data outlives the period during which the output struct is in scope, meaning it is impossible to have dangling pointer errors as a result of losing the input data while the output struct still refers to it.
Zero-copy deserialization is discussed in more detail on this page of the website.
<a id="remote-derive"></a>
One recurrent struggle with Serde is needing to use types from somebody else's crate where they do not provide Serialize and Deserialize impls.
Rust's "orphan rule" allows writing a trait impl only if either your crate defines the trait or defines one of the types the impl is for. That means if your code uses a type defined outside of your crate without a Serde impl, you resort to newtype wrappers or other obnoxious workarounds for serializing it.
Serde 1.0 now supports deriving impls for structs and enums defined in other people's crates.
// Serde calls this the definition of the remote type. It is just a copy of the
// remote type. The `remote` attribute gives the path to the actual type.
#[derive(Serialize, Deserialize)]
#[serde(remote = "nifty::Duration")]
struct DurationDef {
secs: i64,
nanos: i32,
}
// Now the remote type can be used almost like it had its own Serialize and
// Deserialize impls all along. The `with` attribute gives the path to the
// definition for the remote type. Note that the real type of the field is the
// remote type, not the definition type.
#[derive(Serialize, Deserialize)]
struct Process {
command_line: String,
#[serde(with = "DurationDef")]
wall_time: nifty::Duration,
}
Remote derive is covered on this page of the website, which also includes an example of handling a remote struct with private fields.
<a id="documentation"></a>
Lots of new content on the Serde website. The following new pages in particular are a valuable read even for experienced Serde users.
<a id="is-serde-done"></a>
As of this release, Serde is stable but not done. We say with confidence that Serde is the best serialization solution that we can design for the Rust language as it exists today and for the broad range of use cases that we target.
The Serde issue tracker has a long list of planned enhancements for you to look forward to and maybe help us implement. For the first time, none of them involve further breaking changes.
<a id="breaking-changes"></a>
<a id="zero-copy-lifetime"></a>Zero-copy deserialization involves tracking a 'de lifetime.
The Deserialize and Deserializer traits as well as some other deserialization-related traits now have a 'de lifetime parameter. These lifetimes enable Serde to perform efficient and safe zero-copy deserialization across a variety of data formats. The website has a page on understanding deserializer lifetimes.
<a id="deserialize-any"></a>Method Deserializer::deserialize has been renamed to deserialize_any.
The old name did nothing to clarify the purpose of this method in contrast to any of the other Deserializer trait methods. Also the existence of a method named deserialize on two different Serde traits sometimes required them to be explicitly disambiguiated using UFCS.
<a id="accessor-traits"></a>Deserializer-provided accessor traits have been renamed.
The SeqVisitor, MapVisitor, EnumVisitor, and VariantVisitor traits have been renamed to SeqAccess, MapAccess, EnumAccess, and VariantAccess. The old names conflicted with the Visitor trait which plays a totally different role, and this was a source of confusion for new and even experienced Serde users. What's more, these accessor traits were never really playing the role of a visitor in any common sense. The are provided by the Deserializer to a Visitor to give it the ability to access elements of a data structure.
<a id="implicit-conversions"></a>Some questionable implicit type conversions are gone.
For example, a JSON null will no longer successfully deserialize if the output type is a string. Such conversions violated the objective that if Serde successfully deserializes some input into a particular data structure, you can be condient that the input matches what your data structure says it should look like.
<a id="into-deserializer"></a>ValueDeserializer has been renamed to IntoDeserializer.
The new name aligns with traits that play a similar role in other parts of the Rust ecosystem, such as IntoIterator and IntoFuture.
<a id="fixed-size-seq"></a>The concept of a fixed-size sequence is gone in favor of tuple.
Previous versions of Serde represented fixed-size arrays like [u64; 3] and tuples like (u64, u64, u64) as different types in the data model. From the perspective of a Serde data format the distinction between these types never matters, so fixed-size sequences have been removed from the data model.
<a id="deserialize-identifier"></a>Method deserialize_struct_field has been renamed to deserialize_identifier.
This method has existed since Serde 0.7 but has always been used for both struct fields and enum discriminants. The new name reflects that this method is used to identify what to deserialize next—whether that is to decide which field of a struct we are looking at, or which variant of an enum.
<a id="variant-indices"></a>Variant indices during deserialization have changed from usize to u32.
Previous versions of Serde treated the index of a variant in an enum as usize while serializing and as u32 while deserializing. This inconsistency has been resolved by standardizing on u32.
<a id="serde-test"></a>The serde_test Token API has been redesigned.
The serde_test crate is great for unit testing implementations of Serialize and Deserialize without being tied to any particular data format. The API had stagnated over the past few releases so this redesign brings it in line with modern naming conventions and Serde concepts.
<a id="builtin-visitors"></a>Built-in visitors are private.
The Visitor implementations used for deserializing standard library types have been made private. These are an implementation detail and were not designed to be used by other crates.
<a id="serde-bytes"></a>Byte-related wrapper types have moved to the serde_bytes crate.
The Bytes and ByteBuf wrappers are a stopgap solution until specialization enables us to handle &[u8] and Vec<u8> in an optimized way by default.
<a id="size-hint"></a>Size hint methods have changed from (lower, upper) bounds to Option<usize>.
The size hint on the standard library Iterator trait returns lower and upper bounds in order to optimize handling of complicated iterator chains. This use case never arises during Serde deserialization; the deserializer either knows the exact length of a sequence or map or has no idea.
<a id="rc-feature"></a>Rc and Arc impls require opting in to a feature.
Serialization of the reference-counted types Rc<T> and Arc<T> was a source of confusion. A single Rc could be serialized multiple times as part of a data structure, then deserialize to multiple copies of itself. If this is the behavior you want, opt in to these impls by enabling the "rc" feature of your Serde dependency.
Remove usage of unstable core::Zero, which was removed upstream (#899, thanks @SimonSapin)
Implement Serialize and Deserialize for Cell\ , RefCell\ , Mutex\ , RwLock\ (#882, thanks @jethrogb)
Support deserializing `OsString` on Windows
OsString on Windows (#838)Add #[serde(into = "T")] to serialize using the implementation of Into and #[serde(from = "T")] to deserialize using the implementation of From (#817,
Add #[serde(into = "T")] to serialize using the implementation of Into<T> and #[serde(from = "T")] to deserialize using the implementation of From<T> (#817, thanks @jbaublitz)
#[derive(Serialize, Deserialize)]
#[serde(into = "u32", from = "u32")]
struct Ipv4Addr {
/* ... */
}
Implement Deserialize for <code>Box<<a href="https://doc.rust-lang.org/std/ffi/struct.CStr.html">CStr</a>></code> on nightly (#811, thanks @jonhoo)
Implement Serialize and Deserialize for OsString and implement Serialize for OsStr (#824, thanks @alexcrichton)
Implement Serialize for Range (#813, thanks @rocallahan)
Implement Serialize and Deserialize for `CString` and implement Serialize for `CStr` (#801, thanks @jonhoo)
CString and implement Serialize for CStr (#801, thanks @jonhoo)Serializer::collect_str to enable zero-allocation serialization of dynamically constructed strings (#789, thanks @nox)Add a rename_all attribute to rename all the fields of a struct or struct variant, or all the variants of an enum.
Add a rename_all attribute to rename all the fields of a struct or struct variant, or all the variants of an enum.
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct S {
first_field: u8, // gets renamed to firstField
second_field: u8, // gets renamed to secondField
}
The possible renames are:
#[serde(rename_all = "PascalCase")]#[serde(rename_all = "camelCase")]#[serde(rename_all = "snake_case")]#[serde(rename_all = "SCREAMING_SNAKE_CASE")]#[serde(rename_all = "kebab-case")]Fix a bug causing externally tagged enums inside of untagged / internally tagged enums to fail to deserialize (#775 and https://github.com/serde-rs/js
Add with = "..." attribute that serves as a combination of serialize_with and deserialize_with
Add with = "..." attribute that serves as a combination of serialize_with and deserialize_with (#763)
#[derive(Serialize, Deserialize)]
struct MyStruct {
- #[serde(serialize_with = "hyper_serde::serialize",
- deserialize_with = "hyper_serde::deserialize")]
+ #[serde(with = "hyper_serde")]
headers: Headers,
}
Whatever path you give, Serde will use $path::serialize as the serializer and $path::deserialize as the deserializer.
Haskell / Pandoc style adjacently tagged enums (#758, thanks @elliottslaughter)
#[derive(Serialize, Deserialize)]
#[serde(tag = "t", content = "c")]
enum MyType {
One(String),
Two(u8, u8),
}
Written in JSON syntax, this enum would be represented as:
{ "t": "One", "c": "whatever string" }
{ "t": "Two", "c": [127, 1] }
Allow serde(default) attribute on structs (#780, thanks @Thomasdezeeuw)
#[derive(Serialize, Deserialize)]
#[serde(default)]
struct StructDefault {
a: i32,
b: String,
}
impl Default for StructDefault {
fn default() -> Self {
StructDefault {
a: 100,
b: "default".to_string(),
}
}
}
Clamp size hints coming from untrusted input to 4096 (#774, thanks @nox)
This mitigates some types of attacks where untrusted input can instigate the allocation of large vectors or maps.
Optimize the serialization of various std::net types (#778, thanks @SimonSapin)
Add `Serializer::collect_seq` and `Serializer::collect_map` to simplify some Serialize impls
Add Serializer::collect_seq and Serializer::collect_map to simplify some Serialize impls (#736)
- let mut map = serializer.serialize_map(Some(self.len()))?;
- for (k, v) in self {
- map.serialize_key(k)?;
- map.serialize_value(v)?;
- }
- map.end()
+ serializer.collect_map(self)
One column per quarter.