src/Zeclib/Compat.php
public static function encodeJson($native)
    {
        if (function_exists('json_decode') && function_exists('json_last_error')) {
            $json = json_encode($native);
            $error = json_last_error();
            if ($error !== JSON_ERROR_NONE) {
                $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'error code: ' . $error;
                throw new RuntimeException($message, $error);
            }
            return $json;
        }

        $encoder = new Services_JSON();
        $json = $encoder->encode($native);
        if (Services_JSON::isError($json)) {
            throw new RuntimeException($json->toString(), $json->getCode());
        }

        return $json;
    }
public static function encodeJson($native)
    {
        if (function_exists('json_decode') && function_exists('json_last_error')) {
            $json = json_encode($native);
            $error = json_last_error();
            if ($error !== JSON_ERROR_NONE) {
                $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'error code: ' . $error;
                throw new RuntimeException($message, $error);
            }
            return $json;
        }

        $encoder = new Services_JSON();
        $json = $encoder->encode($native);
        if (Services_JSON::isError($json)) {
            throw new RuntimeException($json->toString(), $json->getCode());
        }

        return $json;
    }
値を JSON 形式の文字列に変換します。

@param mixed $native
@throws RuntimeException
@return string