-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialization round-trip fails with empty Vec #78
Comments
Hey @dfaust! Thanks for opening an issue. You raise an interesting problem. I'm struggling to come up with a way that we could solve this on the One thing you could maybe do as a workaround it: #[test]
fn serialization_roundtrip() {
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
struct Data {
#[serde(default)] // <<<<< use this
values: Vec<String>,
}
let data = Data { values: Vec::new() };
let serialized = serde_qs::to_string(&data).unwrap();
dbg!(&serialized);
let deserialized = serde_qs::from_str::<Data>(&serialized).unwrap();
assert_eq!(deserialized, data);
} Do you think that would be possible? |
Thanks @samscott89 for the quick reply!
Sure. That's an easy enough work-around. 👍 I still hope that you can find a solution though, since this behavior is quite surprising. Anyway, I still love your crate. Being able to serialize |
Issue also occurs with an empty |
When serializing a struct containing an empty
Vec
, theVec
is completely dropped.But when de-serializing the struct, the
Vec
is required.This breaks the serialization round-trip.
My expectation is that the de-serializing should work, even if the
Vec
is not present.Here is an example:
The text was updated successfully, but these errors were encountered: