com.cmonbaby.http.converter.FastJsonResponseBodyConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http_lower Show documentation
Show all versions of http_lower Show documentation
Android Http Core Library
package com.cmonbaby.http.converter;
import com.alibaba.fastjson.JSON;
import java.io.IOException;
import java.lang.reflect.Type;
import okhttp3.ResponseBody;
import okio.BufferedSource;
import okio.Okio;
import retrofit2.Converter;
/**
* Author: Simon
*
QO: 8950764
*
Email: [email protected]
*
WebSize: https://www.cmonbaby.com
*
Version: 1.0.0
*
Date: 2020/12/28
*
Description: 返回体
*/
final class FastJsonResponseBodyConverter implements Converter {
private final Type type;
FastJsonResponseBodyConverter(Type type) {
this.type = type;
}
/**
* 转换方法
*/
@Override
public T convert(ResponseBody value) throws IOException {
BufferedSource bufferedSource = Okio.buffer(value.source());
String tempStr = bufferedSource.readUtf8();
bufferedSource.close();
return JSON.parseObject(tempStr, type);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy