Package | Description |
---|---|
org.dromara.hutool.core.bean.path |
Bean路径,通过路径表达式查找或设置对象或子对象中的值
|
org.dromara.hutool.json |
JSON(JavaScript Object Notation JavaScript对象表示法)封装
规范见:https://www.rfc-editor.org/rfc/rfc8259 包含以下组件: JSONObject: 使用键值对表示的数据类型,使用"{}"包围 JSONArray: 使用列表表示的数据类型,使用"[]"包围 JSONPrimitive:表示boolean、String、Number等原始类型 JSON封装主要包括JSON表示和JSON转换:
<-----JSONMapper----- <---JSONParser----
Java对象 <====================> JSON对象 <=================> JSON字符串
-----JSONMapper-----> ---JSONWriter---->
当然,为了高效转换,如果没有自定义需求,Java对象可以不通过JSON对象与JSON字符串转换:
JSONTokener:JSON字符串底层解析器,通过Stream方式读取JSON字符串并对不同字段自定义处理。 |
org.dromara.hutool.json.support |
JSON的支持类,如用于转换和BeanPath操作的对象,还有用于格式化的对象等
|
Modifier and Type | Method and Description |
---|---|
BeanPath<T> |
BeanPath.next() |
static BeanPath<Object> |
BeanPath.of(String expression)
创建Bean路径
|
static <T> BeanPath<T> |
BeanPath.of(String expression,
NodeBeanFactory<T> beanFactory)
创建Bean路径
|
Modifier and Type | Method and Description |
---|---|
Object |
DefaultNodeBeanFactory.create(Object parent,
BeanPath<Object> beanPath) |
T |
NodeBeanFactory.create(T parent,
BeanPath<T> beanPath)
创建Bean
beanPath对应当前的路径,即如果父对象为:a,则beanPath为:a.b,则创建的Bean为:a.b.c对应的Bean对象 给定的a一定存在,但是本路径中b对应的Bean不存在,则创建的对象是b的值,这个值用c表示 |
Object |
DefaultNodeBeanFactory.getValue(Object bean,
BeanPath<Object> beanPath) |
Object |
NodeBeanFactory.getValue(T bean,
BeanPath<T> beanPath)
获取Bean对应节点的值
|
Object |
DefaultNodeBeanFactory.setValue(Object bean,
Object value,
BeanPath<Object> beanPath) |
T |
NodeBeanFactory.setValue(T bean,
Object value,
BeanPath<T> beanPath)
设置节点值
|
Modifier and Type | Method and Description |
---|---|
BeanPath<JSON> |
JSONFactory.ofBeanPath(String expression)
创建BeanPath,用于使用路径方式访问或设置值
|
Modifier and Type | Method and Description |
---|---|
JSON |
JSONNodeBeanFactory.create(JSON parent,
BeanPath<JSON> beanPath) |
Object |
JSONNodeBeanFactory.getValue(JSON bean,
BeanPath<JSON> beanPath) |
JSON |
JSONNodeBeanFactory.setValue(JSON bean,
Object value,
BeanPath<JSON> beanPath) |
Copyright © 2025. All rights reserved.