All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.jfunc.common.http.withconverter.json.JsonConverterOkHttp3SmartHttpClient Maven / Gradle / Ivy

Go to download

http客户端请求工具类,有多种实现:OKHttp3、ApacheHttpClient、HttpURLConnection,可以随意切换http实现

There is a newer version: 1.8.2.0
Show newest version
package top.jfunc.common.http.withconverter.json;

import top.jfunc.common.converter.Converter;
import top.jfunc.common.converter.JsonConverter;
import top.jfunc.common.http.withconverter.ConverterOkHttp3SmartHttpClient;
import top.jfunc.json.JsonArray;
import top.jfunc.json.JsonObject;

import java.util.Objects;

/**
 * 返回结果String转换为Json
 * @author xiongshiyan at 2018/1/11
 */
public class JsonConverterOkHttp3SmartHttpClient extends ConverterOkHttp3SmartHttpClient implements JsonConverterSmartHttpClient {

    private JsonConverter converter;
    public JsonConverterOkHttp3SmartHttpClient(JsonConverter converter){
        super(converter);
    }
    public JsonConverterOkHttp3SmartHttpClient(){}

    @Override
    public JsonConverterSmartHttpClient setConverter(JsonConverter converter) {
        super.setConverter(converter);
        this.converter = Objects.requireNonNull(converter);
        return this;
    }

    @Override
    public JsonObject convertJsonObject(String src) {
        Converter.checkNull(this.converter);
        return this.converter.convertJsonObject(src);
    }

    @Override
    public JsonArray convertJsonArray(String src) {
        Converter.checkNull(this.converter);
        return this.converter.convertJsonArray(src);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy