修复NumberWithFormat没有实现Comparable接口导致的JSON排序报错问题(issue#ID61QR@Gitee)

This commit is contained in:
Looly
2025-11-12 22:22:29 +08:00
parent 9b3414b397
commit 41307a6e3d
4 changed files with 32 additions and 3 deletions
@@ -0,0 +1,19 @@
package cn.hutool.json;
import cn.hutool.core.map.MapUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Map;
public class IssueID61QRTest {
@Test
public void testName() {
JSONObject map1 = JSONUtil.createObj(new JSONConfig().setDateFormat("yyyy"));
// JSONObject map1 = JSONUtil.createObj();
map1.set("a", 3);
map1.set("b", 5);
map1.set("c", 5432);
Assertions.assertEquals("{c=5432, b=5, a=3}", MapUtil.sortByValue(JSONUtil.toBean(map1, Map.class), true).toString());
}
}