Open Gordon01 opened 1 year ago
Oof, thanks for finding that and raising!
Would you be up for working on a fix?
Unfortunately, I couldn't make it to work due to my relatively low experience with serde
.
I've just made an ad-hoc solution that worked in my case:
fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
<T as FromStr>::Err: fmt::Display,
{
v.split(',')
.map(|i| i.parse::<T>().map_err(E::custom))
.collect()
}
I would be much happier in making a PR, adding such functionality into serde_qs
itself because too many people need such a parser for sequences.
Something like a:
#[derive(Serialize, Deserialize)]
struct Users {
#[serde_qs(value_delimiter = ",")]
users: Vec<u64>,
}
instead of
#[derive(Serialize, Deserialize)]
struct Users {
#[serde(default, deserialize_with = "deserialize_list")]
users: Vec<u64>,
}
would be much greater)
But I don't know how to code it right now (
I've added a test in this PR https://github.com/samscott89/serde_qs/pull/82 which highlights the problem: