jonasbb / serde_with

This crate provides custom de/serialization helpers to use in combination with serde's `with`-annotation and with the improved `serde_as`-annotation.
https://docs.rs/serde_with
Apache License 2.0
636 stars 67 forks source link

how to deserialize duration like 30s #727

Closed caibirdme closed 5 months ago

caibirdme commented 5 months ago

{"timeout":"1m30s"}

struct Foo {
  // how to deserialize this?
  timeout std::time::Duration
}
jonasbb commented 5 months ago

Maybe you can use https://docs.rs/humantime-serde/ for this. I do not plan to add such string/time parsing code to serde_with.