serde_with v1.14.0
github-actions
released this
29 May 16:52
·
576 commits
to master
since this release
Added
-
Add support for
time
crate v0.3 #450time::Duration
can now be serialized with theDurationSeconds
and related converters.// Rust #[serde_as(as = "serde_with::DurationSeconds<u64>")] value: Duration, // JSON "value": 86400,
time::OffsetDateTime
andtime::PrimitiveDateTime
can now be serialized with theTimestampSeconds
and related converters.// Rust #[serde_as(as = "serde_with::TimestampMicroSecondsWithFrac<String>")] value: time::PrimitiveDateTime, // JSON "value": "1000000",
time::OffsetDateTime
can be serialized in string format in different well-known formats.
Two formats are supported,time::format_description::well_known::Rfc2822
andtime::format_description::well_known::Rfc3339
.// Rust #[serde_as(as = "time::format_description::well_known::Rfc2822")] rfc_2822: OffsetDateTime, #[serde_as(as = "Vec<time::format_description::well_known::Rfc3339>")] rfc_3339: Vec<OffsetDateTime>, // JSON "rfc_2822": "Fri, 21 Nov 1997 09:55:06 -0600", "rfc_3339": ["1997-11-21T09:55:06-06:00"],
-
Deserialize
bool
from integers #456 462Deserialize an integer and convert it into a
bool
.
BoolFromInt<Strict>
(default) deserializes 0 tofalse
and1
totrue
, other numbers are errors.
BoolFromInt<Flexible>
deserializes any non-zero astrue
.
Serialization only emits 0/1.// Rust #[serde_as(as = "BoolFromInt")] // BoolFromInt<Strict> b: bool, // JSON "b": 1,
Changed
- Bump MSRV to 1.53, since the new dependency
time
requires that version.
Fixed
- Make the documentation clearer by stating that the
#[serde_as]
and#[skip_serializing_none]
attributes must always be places before#[derive]
.