Expand description
Turning query strings and form bodies into a uniform JSON tree.
Everything downstream of the request — input(), validation rules,
Form<T> deserialisation — reads one shape: a serde_json::Value. A JSON
body already is one; a query string or a urlencoded form has to be lifted
into one, and that lift is where PHP-style bracket notation is honoured:
| Query | Value |
|---|---|
a=1&b=2 | {"a": "1", "b": "2"} |
tags[]=x&tags[]=y | {"tags": ["x", "y"]} |
user[name]=ada | {"user": {"name": "ada"}} |
a=1&a=2 | {"a": ["1", "2"]} |
Values stay strings. A form has no types — ?active=1 could be the
number one or the string “1” — so guessing here would make
Form<T>/validation behaviour depend on what the value happened to look
like. Coercion is the validator’s job, where the expected type is known.
Functions§
- lookup
- Read a dotted path out of a JSON tree.
items.0.nameindexes arrays. - merge
- Merge
overlayoverbase, recursing into objects. - parse_
urlencoded - Parse
application/x-www-form-urlencodedbytes (a query string or a form body) into a JSON object. - scalar_
to_ string - Render a JSON value as the string an
input()caller expects.