com.hp.message.convert.FastJsonRequestConverter Maven / Gradle / Ivy
package com.hp.message.convert;
import com.alibaba.fastjson.JSON;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Converter;
import java.io.IOException;
/**
* @author 尚肖磊
* @create 2021-06-10 18:33
* @Description: api请求转换类
*/
public class FastJsonRequestConverter implements Converter {
private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
@Override
public RequestBody convert(T value) throws IOException {
return RequestBody.create(MEDIA_TYPE, JSON.toJSONBytes(value));
}
}