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

cn.wandersnail.common.http.converter.FastJsonRequestBodyConverter Maven / Gradle / Ivy

There is a newer version: 2.2.1
Show newest version
package cn.wandersnail.common.http.converter;

import com.alibaba.fastjson.JSON;

import java.io.IOException;

import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Converter;

/**
 * 使用阿里巴巴的FastJson转换请求体
 * 
 * date: 2019/8/23 14:59
 * author: zengfansheng
 */
public class FastJsonRequestBodyConverter implements Converter {

    @Override
    public RequestBody convert(Object value) throws IOException {
        MediaType mediaType = MediaType.parse("application/json; charset=UTF-8");
        return RequestBody.create(mediaType, JSON.toJSONBytes(value));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy