Ouzo\Utilities\Json::decode PHP Method

decode() public static method

Decodes a JSON string, or throws JsonDecodeException on failure
public static decode ( string $string, boolean $asArray = false ) : mixed
$string string
$asArray boolean
return mixed
    public static function decode($string, $asArray = false)
    {
        $decoded = self::safeDecode($string, $asArray);
        if (is_null($decoded) == false) {
            return $decoded;
        }
        $code = self::lastError();
        if ($code == JSON_ERROR_NONE) {
            return $decoded;
        }
        throw new JsonDecodeException(self::lastErrorMessage(), $code);
    }

Usage Example

Ejemplo n.º 1
0
 public function handle($data)
 {
     $method = $data['method'];
     $restData = Json::decode($data['rest_data']);
     $class = '\\Tests\\MockSugarServer\\Action\\' . Strings::underscoreToCamelCase($method);
     $action = new $class($restData);
     return $action->process()->response();
 }
All Usage Examples Of Ouzo\Utilities\Json::decode