#serde #object #nested #style #serializing-deserializing #key #querystrings

nested_qs

Serializing/deserializing nested style querystrings with serde

3 releases

Uses old Rust 2015

0.1.2 Jul 6, 2020
0.1.1 Nov 10, 2017
0.1.0 Nov 9, 2017

#2022 in Encoding

MIT/Apache

24KB
634 lines

Nested querystrings with serde

Deserializes x-www-form-urlencoded strings/bytes into deserializable structs and vice versa.

Similar to and inspired by serde_qs.

Defers pretty much everything except key parsing to url::form_urlencoded and serde_json.

serde_json::Value is used as an intermediate object between the string and your struct. However, this is not as expensive as might be expected (you'll probably need to allocate a few strings anyway if you have any pluses or encoded chars in your querystring). Some casual benchmarking indicates it performs well in comparison to serde_qs.

Using serde_json::Value like this does not mean that JSON is used in the process. No JSON strings are involved at any point.

Use like:

let decoded: MyStruct = nested_qs::from_str(&encoded)?;
let encoded = nested_qs::to_string(&decoded)?;

Dependencies

~4–10MB
~129K SLoC