mirror of
https://gitee.com/dromara/hutool.git
synced 2026-02-09 09:16:26 +08:00
修复ObjectMapper过滤器对Bean复制无效的问题(pr#1431@Gitee)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
# 🚀Changelog
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.43(2025-12-31)
|
||||
# 5.8.43(2026-01-03)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 `ColorUtil`颜色名称DARKGOLD、LIGHTGOLD新增蛇形命名匹配(pr#1400@Github)
|
||||
@@ -33,6 +33,7 @@
|
||||
* 【core 】 修复`StrUtil.truncateByByteLength`在限制长度小于...时报错问题(issue#IDFTJS@Gitee)
|
||||
* 【core 】 修复`Calculator.conversion`方法计算包含%连接一元运算符的计算表达式的结果时逻辑缺陷(pr#4191@Github)
|
||||
* 【db 】 修复`SqlUtil.PATTERN_IN_CLAUSE`逻辑缺陷导致in语句参数不正确的问题(pr#4203@Github)
|
||||
* 【json 】 修复`ObjectMapper`过滤器对Bean复制无效的问题(pr#1431@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.42(2025-11-28)
|
||||
|
||||
@@ -184,11 +184,7 @@ public final class InternalJSONUtil {
|
||||
* @since 5.8.0
|
||||
*/
|
||||
static CopyOptions toCopyOptions(JSONConfig config) {
|
||||
return CopyOptions.create()
|
||||
.setIgnoreCase(config.isIgnoreCase())
|
||||
.setIgnoreError(config.isIgnoreError())
|
||||
.setIgnoreNullValue(config.isIgnoreNullValue())
|
||||
.setTransientSupport(config.isTransientSupport());
|
||||
return toCopyOptions(config, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,6 +193,7 @@ public final class InternalJSONUtil {
|
||||
* @param config {@link JSONConfig}
|
||||
* @param filter {@link Filter}
|
||||
* @return {@link CopyOptions}
|
||||
* @since 5.8.43
|
||||
*/
|
||||
static CopyOptions toCopyOptions(JSONConfig config, Filter<MutablePair<String, Object>> filter) {
|
||||
CopyOptions copyOptions = CopyOptions.create()
|
||||
|
||||
30
hutool-json/src/test/java/cn/hutool/json/Pr1431Test.java
Normal file
30
hutool-json/src/test/java/cn/hutool/json/Pr1431Test.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class Pr1431Test {
|
||||
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
|
||||
@Test
|
||||
void filterTest() {
|
||||
UserC user = new UserC();
|
||||
user.setId(1);
|
||||
user.setName("张三");
|
||||
user.setProp("123456");
|
||||
|
||||
final JSONObject entries = new JSONObject(user, JSONConfig.create(), pair -> !"prop".equals(pair.getKey()));
|
||||
assertEquals(2, entries.size());
|
||||
assertTrue(entries.containsKey("id"));
|
||||
assertTrue(entries.containsKey("name"));
|
||||
}
|
||||
|
||||
@Data
|
||||
static class UserC {
|
||||
private int id;
|
||||
private String name;
|
||||
private String prop;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user