function Utils::jsonDecode
Wrapper for json_decode that throws when an error occurs.
Parameters
string $json JSON data to parse:
bool $assoc When true, returned objects will be converted: into associative arrays.
int $depth User specified recursion depth.:
int $options Bitmask of JSON decode options.:
Return value
object|array|string|int|float|bool|null
Throws
InvalidArgumentException if the JSON cannot be decoded.
See also
https://www.php.net/manual/en/function.json-decode.php
2 calls to Utils::jsonDecode()
- FileCookieJar::load in vendor/
guzzlehttp/ guzzle/ src/ Cookie/ FileCookieJar.php - Load cookies from a JSON formatted file.
- json_decode in vendor/
guzzlehttp/ guzzle/ src/ functions.php - Wrapper for json_decode that throws when an error occurs.
File
-
vendor/
guzzlehttp/ guzzle/ src/ Utils.php, line 273
Class
Namespace
GuzzleHttpCode
public static function jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0) {
$data = \json_decode($json, $assoc, $depth, $options);
if (\JSON_ERROR_NONE !== \json_last_error()) {
throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
}
return $data;
}