#serde #object #key #nested #style #serializing-deserializing #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

#1866 in Encoding

Download history 9/week @ 2024-02-21 12/week @ 2024-02-28 2/week @ 2024-03-06 16/week @ 2024-03-13 18/week @ 2024-03-27 37/week @ 2024-04-03

55 downloads per month

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.5–6.5MB
~153K SLoC