mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复ignoreNullValue在JSONArray中无效问题
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user