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

com.cmonbaby.http.converter.FastJsonResponseBodyConverter Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
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