private function decodeJson($json)
{
$assoc = self::ASSOC_ARRAY === $this->objectDecoding;
if (PHP_VERSION_ID >= 50400 && !defined('JSON_C_VERSION')) {
$options = self::STRING === $this->bigIntDecoding ? JSON_BIGINT_AS_STRING : 0;
$decoded = json_decode($json, $assoc, $this->maxDepth, $options);
} else {
$decoded = json_decode($json, $assoc, $this->maxDepth);
}
// Data could not be decoded
if (null === $decoded && 'null' !== $json) {
$parser = new JsonParser();
$e = $parser->lint($json);
if ($e instanceof ParsingException) {
throw new DecodingFailedException(sprintf('The JSON data could not be decoded: %s.', $e->getMessage()), 0, $e);
}
// $e is null if json_decode() failed, but the linter did not find
// any problems. Happens for example when the max depth is exceeded.
throw new DecodingFailedException(sprintf('The JSON data could not be decoded: %s.', JsonError::getLastErrorMessage()), json_last_error());
}
return $decoded;
}