private function decode($json)
	{
		// Attempt to fix bad UTF-8 data when the right flag is set on the client
		if (BaseClient::$flags & BaseClient::FLAG_ATTEMPT_UTF8_RECOVERY)
			if (!preg_match("//u", $json))
				$json = utf8_encode(utf8_decode($json));
		
		$response = json_decode($json);
		$errorCode = json_last_error();

		switch ($errorCode)
		{
			case JSON_ERROR_DEPTH:
				$errorDescription = 'Maximum stack depth exceeded';
				break;
			case JSON_ERROR_STATE_MISMATCH:
				$errorDescription = 'Underflow or the modes mismatch';
				break;
			case JSON_ERROR_CTRL_CHAR:
				$errorDescription = 'Unexpected control character found';
				break;
			case JSON_ERROR_SYNTAX:
				$errorDescription = 'Syntax error, malformed JSON';
				break;
			case JSON_ERROR_UTF8:
				$errorDescription = 'Malformed UTF-8 characters, possibly incorrectly encoded';
				break;
			default:
				$errorDescription = 'Unknown error';
				break;
		}

		if ($errorCode !== JSON_ERROR_NONE)
			throw new Exception\InvalidResponseException('Unable to decode JSON response: '.$errorDescription, $errorCode);

		return $response;
	}
private function decode($json)
	{
		// Attempt to fix bad UTF-8 data when the right flag is set on the client
		if (BaseClient::$flags & BaseClient::FLAG_ATTEMPT_UTF8_RECOVERY)
			if (!preg_match("//u", $json))
				$json = utf8_encode(utf8_decode($json));
		
		$response = json_decode($json);
		$errorCode = json_last_error();

		switch ($errorCode)
		{
			case JSON_ERROR_DEPTH:
				$errorDescription = 'Maximum stack depth exceeded';
				break;
			case JSON_ERROR_STATE_MISMATCH:
				$errorDescription = 'Underflow or the modes mismatch';
				break;
			case JSON_ERROR_CTRL_CHAR:
				$errorDescription = 'Unexpected control character found';
				break;
			case JSON_ERROR_SYNTAX:
				$errorDescription = 'Syntax error, malformed JSON';
				break;
			case JSON_ERROR_UTF8:
				$errorDescription = 'Malformed UTF-8 characters, possibly incorrectly encoded';
				break;
			default:
				$errorDescription = 'Unknown error';
				break;
		}

		if ($errorCode !== JSON_ERROR_NONE)
			throw new Exception\InvalidResponseException('Unable to decode JSON response: '.$errorDescription, $errorCode);

		return $response;
	}
private function decode ( $ json ) { // Attempt to fix bad UTF-8 data when the right flag is set on the client if ( BaseClient :: $ flags & BaseClient :: FLAG_ATTEMPT_UTF8_RECOVERY ) if ( ! preg_match ( "//u" , $ json ) ) $ json = utf8_encode ( utf8_decode ( $ json ) ) ; $ response = json_decode ( $ json ) ; $ errorCode = json_last_error ( ) ; switch ( $ errorCode ) { case JSON_ERROR_DEPTH : $ errorDescription = 'Maximum stack depth exceeded' ; break ; case JSON_ERROR_STATE_MISMATCH : $ errorDescription = 'Underflow or the modes mismatch' ; break ; case JSON_ERROR_CTRL_CHAR : $ errorDescription = 'Unexpected control character found' ; break ; case JSON_ERROR_SYNTAX : $ errorDescription = 'Syntax error, malformed JSON' ; break ; case JSON_ERROR_UTF8 : $ errorDescription = 'Malformed UTF-8 characters, possibly incorrectly encoded' ; break ; default : $ errorDescription = 'Unknown error' ; break ; } if ( $ errorCode !== JSON_ERROR_NONE ) throw new Exception \ InvalidResponseException ( 'Unable to decode JSON response: ' . $ errorDescription , $ errorCode ) ; return $ response ; }
Decodes the supplied JSON string, throwing an exception if decoding fails
@param string $json the raw JSON string
@return stdClass the decoded object
@throws SimpleJsonRpcClient\Exception\BaseException
Decodes the supplied JSON string throwing an exception if decoding fails