Skip to main content

encode

Function encode 

Source
pub fn encode<X: Extension>(
    value: &Value<X>,
    flags: Flags,
    depth: i64,
) -> Result<String, Error>
Expand description

json_encode($value, $flags, $depth).

Returns the JSON text, or the error PHP reports: Err(Error::Json) where PHP returns false (or throws with JSON_THROW_ON_ERROR), and Err(Error::Partial) carrying the output PHP returns when JSON_PARTIAL_OUTPUT_ON_ERROR is set. depth is cast to a C int like PHP does; it is not validated (a depth below 1 fails on any array).