Skip navigation links
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
hutool
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
cn.hutool.json
Class ObjectMapper
java.lang.Object
cn.hutool.json.ObjectMapper
public class ObjectMapper
extends Object
对象和JSON映射器,用于转换对象为JSON,支持:
Map 转 JSONObject,将键值对加入JSON对象
Map.Entry 转 JSONObject
CharSequence 转 JSONObject,使用JSONTokener解析
Reader 转 JSONObject,使用JSONTokener解析
InputStream 转 JSONObject,使用JSONTokener解析
JSONTokener 转 JSONObject,直接解析
ResourceBundle 转 JSONObject
Bean 转 JSONObject,调用其getters方法(getXXX或者isXXX)获得值,加入到JSON对象。例如:如果JavaBean对象中有个方法getName(),值为"张三",获得的键值对为:name: "张三"
Since:
5.8.0
Author:
looly
Constructor Summary
Constructors
Constructor and Description
ObjectMapper(Object source)
构造
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
void
map(JSONArray jsonArray,
Filter filter)
初始化
void
map(JSONObject jsonObject,
Filter filter)
将给定对象转换为JSONObject
static ObjectMapper
of(Object source)
创建ObjectMapper
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail
ObjectMapper
public ObjectMapper(Object source)
构造
Parameters:
source - 来源对象
Method Detail
of
public static ObjectMapper of(Object source)
创建ObjectMapper
Parameters:
source - 来源对象
Returns:
ObjectMapper
map
public void map(JSONObject jsonObject,
Filter filter)
将给定对象转换为JSONObject
Parameters:
jsonObject - 目标JSONObject
filter - 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作
map
public void map(JSONArray jsonArray,
Filter filter)
throws JSONException
初始化
Parameters:
jsonArray - 目标JSONArray
filter - 键值对过滤编辑器,可以通过实现此接口,完成解析前对值的过滤和修改操作,null表示不过滤
Throws:
JSONException - 非数组或集合
Skip navigation links
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
Prev Class
Next Class
Frames
No Frames
All Classes
Summary:
Nested |
Field |
Constr |
Method
Detail:
Field |
Constr |
Method
Copyright © 2023. All rights reserved.
|