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