public T deserialize()

in src/main/java/com/alibaba/yjopenapi/client/api/ApiClient.java [355:389]


    public <T> T deserialize(Response response, Class<T> returnType) throws ApiException {
        if (response == null || returnType == null) {
            return null;
        }

        String respBody;
        try (ResponseBody body = response.body()) {
            if (body != null) {
                respBody = body.string();
            } else {
                respBody = null;
            }
        } catch (IOException e) {
            throw new ApiException(e);
        }

        if (respBody == null || "".equals(respBody)) {
            return null;
        }

        String contentType = response.headers().get("Content-Type");
        if (contentType == null) {
            // ensuring a default content type
            contentType = "application/json";
        }
        if (isJsonMime(contentType)) {
            return JSON.parseObject(respBody, returnType);
        } else {
            throw new ApiException(
                    "Content type \"" + contentType + "\" is not supported for type: " + returnType,
                    response.code(),
                    response.headers().toMultimap(),
                    respBody);
        }
    }