You are here

function json_decode in Lockr 7.3

Wrapper for json_decode that throws when an error occurs.

@link http://www.php.net/manual/en/function.json-decode.php

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

mixed

Throws

\InvalidArgumentException if the JSON cannot be decoded.

File

vendor/guzzlehttp/guzzle/src/functions.php, line 300

Namespace

GuzzleHttp

Code

function json_decode($json, $assoc = false, $depth = 512, $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;
}