![JAR search and dependency download from the Maven repository](/logo.png)
com.alibaba.fastjson.support.retrofit.Retrofit2ConverterFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fastjson-to-easyjson Show documentation
Show all versions of fastjson-to-easyjson Show documentation
Adapter alibaba fastjson to other json libraries. the fastjson version: 1.2.58
package com.alibaba.fastjson.support.retrofit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
/**
* @author ligboy, wenshao
* @author Victor.Zxy
*/
public class Retrofit2ConverterFactory extends Converter.Factory {
private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
private FastJsonConfig fastJsonConfig;
@Deprecated
private static final Feature[] EMPTY_SERIALIZER_FEATURES = new Feature[0];
@Deprecated
private ParserConfig parserConfig = ParserConfig.getGlobalInstance();
@Deprecated
private int featureValues = JSON.DEFAULT_PARSER_FEATURE;
@Deprecated
private Feature[] features;
@Deprecated
private SerializeConfig serializeConfig;
@Deprecated
private SerializerFeature[] serializerFeatures;
public Retrofit2ConverterFactory() {
this.fastJsonConfig = new FastJsonConfig();
}
public Retrofit2ConverterFactory(FastJsonConfig fastJsonConfig) {
this.fastJsonConfig = fastJsonConfig;
}
public static Retrofit2ConverterFactory create() {
return create(new FastJsonConfig());
}
public static Retrofit2ConverterFactory create(FastJsonConfig fastJsonConfig) {
if (fastJsonConfig == null) throw new NullPointerException("fastJsonConfig == null");
return new Retrofit2ConverterFactory(fastJsonConfig);
}
@Override
public Converter responseBodyConverter(Type type, //
Annotation[] annotations, //
Retrofit retrofit) {
return new ResponseBodyConverter
© 2015 - 2025 Weber Informatics LLC | Privacy Policy