Function serde_qs::to_string

source ·
pub fn to_string<T: Serialize>(input: &T) -> Result<String, Error>
Expand description

Serializes a value into a querystring.

#[derive(Deserialize, Serialize)]
struct Query {
    name: String,
    age: u8,
    occupation: String,
}

let q =  Query {
    name: "Alice".to_owned(),
    age: 24,
    occupation: "Student".to_owned(),
};


assert_eq!(
    serde_qs::to_string(&q).unwrap(),
    "name=Alice&age=24&occupation=Student");