URL-Encoded
URL-encoded format (application/x-www-form-urlencoded).
It's very common (especially with older APIs) to use a URL-encoded format as a message body instead of JSON.
#[main]
fn main() {
const object = new {
a: "hello",
b: 42,
c: true,
};
const encoded = stringify("urlencoded", object);
assert_eq(encoded, "a=hello&b=42&c=true");
const import = new {};
parse(encoded, import, "urlencoded");
assert_eq(import.a, "hello");
assert_eq(import.b, 42);
assert_eq(import.c, true);
}Last updated
Was this helpful?