UTILITY

json_try_decode()

Decode JSON without throwing; return the supplied default on invalid JSON.

Signature

mixed json_try_decode(string $json, bool $associative = true, mixed $default = null)

Example

json_try_decode('{bad}', true, []); // []

Available from: 1.5.0

Reference navigation

Previous: is_uuid()

Next: json_try_encode()

Back to utilities