Skip to main content

decode

Function decode 

Source
pub fn decode(
    json: &[u8],
    assoc: Option<bool>,
    depth: i64,
    flags: Flags,
) -> Result<Value, Error>
Expand description

json_decode($json, $assoc, $depth, $flags).

assoc overrides JSON_OBJECT_AS_ARRAY in flags when it is not None, as in PHP. Objects decode to Value::Object (stdClass) or, in array mode, to Value::Array with PHP’s key rules ("7" is key 7). Errors: Error::Json with PHP’s code (empty input is a syntax error), Error::Value when depth is not in 1..=i32::MAX.