public class GsonEngine extends AbstractJSONEngine implements Wrapper<com.google.gson.Gson>
config| Constructor and Description |
|---|
GsonEngine()
构造
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
deserialize(Reader reader,
Object type)
解析JSON数据(反序列化),用于从Reader中读取JSON字符串,转换为Bean对象
type此处定义为Object,因为不同引擎对Type的定义不同,尤其是出现泛型定义时,需要传入引擎自身实现的TypeReference |
com.google.gson.Gson |
getRaw()
获取原始对象
|
protected void |
initEngine()
初始化引擎,实现逻辑中如果初始化完成,不再重新初始化
|
protected void |
reset()
重置引擎
|
void |
serialize(Object bean,
OutputStream out)
生成JSON数据(序列化),用于将指定的Bean对象通过Writer写出为JSON字符串
|
String |
toJsonString(Object bean)
将Java Bean(POJO)对象转换为JSON字符串
|
initclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitfromJsonStringpublic com.google.gson.Gson getRaw()
Wrapperpublic void serialize(Object bean, OutputStream out)
JSONEngineserialize in interface JSONEnginebean - Java Bean(POJO)对象out - 写出到的OutputStreampublic String toJsonString(Object bean)
JSONEnginetoJsonString in interface JSONEnginebean - Java Bean(POJO)对象public <T> T deserialize(Reader reader, Object type)
JSONEnginedeserialize in interface JSONEngineT - Java Bean对象类型reader - 读取JSON的Readertype - Java Bean(POJO)对象类型,可以为Class<T>或者TypeReferenceprotected void reset()
AbstractJSONEnginereset in class AbstractJSONEngineprotected void initEngine()
AbstractJSONEngineinitEngine in class AbstractJSONEngineCopyright © 2025. All rights reserved.