params
ModuleRequest parameters as JSON values: parsing query strings, form bodies and
JSON bodies into Params.
Lists are arrays, maps with other keys are objects, and an empty JSON object stays an empty object.
Contents
use utopia_http::array_to_params;pub fn array_to_params(array: &Array) -> ParamsConverts a php_std::Array into params, with keys as strings, in order.
use utopia_http::decode_payload;pub fn decode_payload(raw: &[u8]) -> ParamsDecodes a JSON body into params.
A top-level object or array gives its members; objects whose keys are
0..n become arrays, and empty objects stay objects. Anything else (a
scalar, an empty object, invalid JSON) gives no params.
use utopia_http::params_value;pub fn params_value(params: &Params) -> ValueParams as a single JSON value: an array when the keys are 0..n (or there
are none), an object otherwise.
use utopia_http::parse_query;pub fn parse_query(input: &str) -> ParamsParses an application/x-www-form-urlencoded string (a query string or a
form body) into params.
Bracketed names build nested values: a[]=x&a[]=y is the array
["x", "y"] and b[k]=v the object {"k": "v"}. Dots and spaces in
names become underscores.
use utopia_http::parse_query_bytes;pub fn parse_query_bytes(input: &[u8]) -> ParamsParses an application/x-www-form-urlencoded byte string into params,
like parse_query.
use utopia_http::value_to_json;pub fn value_to_json(value: &php_std::Value) -> ValueConverts a php_std::Value into a JSON value.
Lists become arrays and other arrays objects. Binary strings are decoded
lossily (params hold UTF-8 only); non-finite floats become null.
pub type Params = Map<String, Value>Decoded request parameters, by name.