mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复ignoreNullValue在JSONArray中无效问题
This commit is contained in:
parent
6d7d0abbba
commit
be98b46349
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.33(2024-09-23)
|
||||
# 5.8.33(2024-09-29)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 SyncFinisher增加setExecutorService方法(issue#IANKQ1@Gitee)
|
||||
@ -21,6 +21,7 @@
|
||||
* 【http 】 修复重定向没有按照RFC7231规范跳转的问题,修改为除了307外重定向使用GET方式(issue#3722@Github)
|
||||
* 【core 】 修复ArrayUtil.lastIndexOfSub死循环问题(issue#IAQ16E@Gitee)
|
||||
* 【core 】 修复ImgUtil.write写出临时文件未清理问题(issue#IAPZG7@Gitee)
|
||||
* 【json 】 修复ignoreNullValue在JSONArray中无效问题(issue#3759@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
**# 5.8.32(2024-08-30)
|
||||
|
@ -594,6 +594,13 @@ public class JSONArray implements JSON, JSONGetter<Integer>, List<Object>, Rando
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// issue#3759
|
||||
final boolean ignoreNullValue = this.config.isIgnoreNullValue();
|
||||
if (ObjectUtil.isNull(obj) && ignoreNullValue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.rawList.add(obj);
|
||||
}
|
||||
}
|
||||
|
14
hutool-json/src/test/java/cn/hutool/json/Issue3759Test.java
Normal file
14
hutool-json/src/test/java/cn/hutool/json/Issue3759Test.java
Normal file
@ -0,0 +1,14 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class Issue3759Test {
|
||||
@Test
|
||||
void parseTest() {
|
||||
String jsonArrayStr = "[null]";
|
||||
final JSONArray objects = JSONUtil.parseArray(jsonArrayStr,
|
||||
JSONConfig.create().setIgnoreNullValue(true));
|
||||
Assertions.assertTrue(objects.isEmpty());
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
package cn.hutool.json;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
Loading…
x
Reference in New Issue
Block a user