77 lines
2.3 KiB
Java
77 lines
2.3 KiB
Java
package cn.citycraft.GsonAgent.api;
|
|
|
|
import java.io.Reader;
|
|
import java.lang.reflect.Type;
|
|
|
|
import cn.citycraft.GsonAgent.api.exception.JsonIOException;
|
|
import cn.citycraft.GsonAgent.api.exception.JsonSyntaxException;
|
|
import cn.citycraft.GsonAgent.api.reflect.TypeToken;
|
|
import cn.citycraft.GsonAgent.api.stream.JsonReader;
|
|
import cn.citycraft.GsonAgent.api.stream.JsonWriter;
|
|
|
|
/**
|
|
* Gson代理API
|
|
* 复制修改于曲尘的Gson
|
|
*
|
|
* @since 2016年1月5日 下午12:48:43
|
|
* @author 喵♂呜
|
|
*/
|
|
public interface Gson {
|
|
public <T> T fromJson(JsonElement json, Class<T> classOfT) throws JsonSyntaxException;
|
|
|
|
public <T> T fromJson(JsonElement json, Type typeOfT) throws JsonSyntaxException;
|
|
|
|
public <T> T fromJson(JsonReader reader, Type typeOfT) throws JsonIOException, JsonSyntaxException;
|
|
|
|
public <T> T fromJson(Reader json, Class<T> classOfT) throws JsonSyntaxException, JsonIOException;
|
|
|
|
public <T> T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException;
|
|
|
|
/**
|
|
* @param result
|
|
* Json字符串
|
|
* @param clazz
|
|
* 模型类
|
|
* @return
|
|
*/
|
|
public <T> T fromJson(final String result, Class<T> clazz) throws JsonSyntaxException;
|
|
|
|
public <T> T fromJson(String json, Type typeOfT) throws JsonSyntaxException;
|
|
|
|
public <T> TypeAdapter<T> getAdapter(Class<T> type);
|
|
|
|
public <T> TypeAdapter<T> getAdapter(TypeToken<T> type);
|
|
|
|
public <T> TypeAdapter<T> getDelegateAdapter(TypeAdapterFactory skipPast, TypeToken<T> type);
|
|
|
|
public String toJson(JsonElement jsonElement);
|
|
|
|
public void toJson(JsonElement jsonElement, Appendable writer) throws JsonIOException;
|
|
|
|
public void toJson(JsonElement jsonElement, JsonWriter writer) throws JsonIOException;
|
|
|
|
/**
|
|
* 对象序列化成Json
|
|
*
|
|
* @param src
|
|
* 对象
|
|
* @return 序列化后的对象
|
|
*/
|
|
public String toJson(Object src);
|
|
|
|
public void toJson(Object src, Appendable writer) throws JsonIOException;
|
|
|
|
public String toJson(Object src, Type typeOfSrc);
|
|
|
|
public void toJson(Object src, Type typeOfSrc, Appendable writer) throws JsonIOException;
|
|
|
|
public void toJson(Object src, Type typeOfSrc, JsonWriter writer) throws JsonIOException;
|
|
|
|
public JsonElement toJsonTree(Object src);
|
|
|
|
public JsonElement toJsonTree(Object src, Type typeOfSrc);
|
|
|
|
@Override
|
|
public String toString();
|
|
}
|