Tags: SimonSapin/serde_urlencoded
Tags
Merge nox#45 45: Fix struct newtype deserialization (and add tests) r=nox a=samsieber Fixes nox#41 I only had to fix the deserializer - the serialization already works. So now they work the same way - you can serialize something and then deserialize it losslessly. I also added tests for serialization and deserialization. Let me know if there's anything you'd like changed. Co-authored-by: Sam Sieber <swsieber@gmail.com>
Merge nox#30 30: Support deserializing a (keyword) string into a unit-only enum r=nox a=smangelsdorf This adds support for deserializing a structure such as: ```rust #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase")] enum SortOrder { Asc, Desc, } #[derive(Serialize, Deserialize, Debug)] struct SearchOptions { sort: SortOrder, } ``` This is already supported for serialization (and I've added a test case for the existing support as part of this PR), but attempting to deserialize the string `"sort=asc"` would result in the error: ``` invalid type: string "asc", expected enum SortOrder ``` I've made a sample in the playground of the way this is handled in `serde_urlencoded` vs `serde_json`: https://play.rust-lang.org/?gist=75fc1e5bbbc1eec29a472373d47488a0&version=stable This brings the behaviour in line with the way `serde_json` currently handles this case, which I hope is appropriate. Happy to tweak the behaviour if there's a better way to handle it. Co-authored-by: Shaun Mangelsdorf <s.mangelsdorf@gmail.com>
Merge nox#25 25: Deserialize () from input without key/value pairs. r=nox Currently there's no input that can be deserialized to `()`, this changes the crate to support deserializing strings without any key/value pair to a `()` (such as the empty string, or just `"&"`). Would be great if you could release a patch for this, I have a project that needs this behavior. EDIT: To expand on my use case, I have a trait which parses the body of an HTTP Request into a type (e.g. for a `POST` request). However, this is abstract over HTTP methods, and its expected to be able to parse an empty body (e.g. from a `GET` request) into `()`.
PreviousNext