mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
add test
This commit is contained in:
parent
51c1588081
commit
c5e1ba85f8
26
hutool-json/src/test/java/cn/hutool/json/Issue3619Test.java
Normal file
26
hutool-json/src/test/java/cn/hutool/json/Issue3619Test.java
Normal file
@ -0,0 +1,26 @@
|
||||
package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Issue3619Test {
|
||||
@Test
|
||||
public void parseObjTest() {
|
||||
String json = "{\"@timestamp\":\"2024-06-14T00:02:06.438Z\",\"@version\":\"1\",\"int_arr\":[-4]}";
|
||||
JSONConfig jsonConfig = JSONConfig.create().setKeyComparator(String.CASE_INSENSITIVE_ORDER);
|
||||
JSONObject jsonObject = JSONUtil.parseObj(json, jsonConfig);
|
||||
|
||||
final String jsonStr = jsonObject.toJSONString(0, pair -> {
|
||||
final Object key = pair.getKey();
|
||||
if(key instanceof String){
|
||||
// 只有key为String时才检查并过滤,其它类型的key,如int类型的key跳过
|
||||
return key.toString().equals("int_arr");
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertEquals("{\"int_arr\":[-4]}", jsonStr);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user