Comments (3)
Hi, thanks for the suggestion. Do you have a concrete improvement in mind? All the examples with chrono::Duration
on the DurationSeconds
page use a more explicitly annotated DurationSeconds
. The comparison table also lists that chrono::Duration
is incompatible with the default format of u64
.
use chrono::Duration;
#[serde_as]
#[derive(Deserialize, Serialize)]
struct Durations {
#[serde_as(as = "DurationSeconds<i64>")]
d_i64: Duration,
#[serde_as(as = "DurationSeconds<f64>")]
d_f64: Duration,
#[serde_as(as = "DurationSeconds<String>")]
d_string: Duration,
};
The example under "Advanced serde_as usage" used std::time::Duration
. That is not directly obvious, since the import is hidden.
from serde_with.
imo
- The example on the crate main page should use the explicit annotation, a example for chrono::Duration might be helpful as well.
- The DurationSeconds page should have a example detailing using
DurationSeconds<i64>
onstd::time::Duration
, or usingDurationSeconds<u64>
onchrono::Duration
are both incorrect.
What do you think?
from serde_with.
I made some changes in #576. I unhid the Duration
import. I don't like the idea of showing wrong examples. I added some explanatory sentences and added some emphasis to the FORMAT
support table for DurationSeconds
/TimestampSeconds
.
from serde_with.
Related Issues (20)
- Vec <-> BTreeMap conversion not available in `no_std` mode
- Non string values in attribute macro HOT 3
- Using serde_with::rust::sets_last_value_wins with serde_as notation HOT 5
- Add `skip_serializing_empty` macro HOT 2
- use serde_with::apply within macro HOT 3
- Deserialize a map into a Vec of keys HOT 2
- deserialize json for String and i32 HOT 1
- Double option pattern with subserializer HOT 2
- bug: serde_json/arbitrary_precision + PickFirst causes issues HOT 2
- Enable std/alloc without other features like chrono HOT 4
- How to combine `double_option` and `serde_as`? HOT 2
- Confusing/Incorrect PickFirst behavior HOT 3
- Compilation fails for targets without `alloc::sync`/atomic pointers
- Wishlist: Blocked on upstream changes
- Suggestion(Seq): Map to Vector of structs HOT 5
- 2.3.0 breaks `HashMap` serialization as `Vec` of pairs with `bincode` HOT 2
- Deserialization doesn't work on hashmap if both generic parameters are constrainted with DeserializeAs types HOT 3
- `DefaultOnError` not behaving like the examples HOT 1
- applying serde_as to whole struct. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serde_with.