修复JSONUtil.toBean()中将JSON数组字符串转Map对象返回错误问题(issue#3795@Github)

This commit is contained in:
Looly
2024-11-24 16:01:28 +08:00
parent d11693fb2d
commit 50807c84d6
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
package cn.hutool.json;
import cn.hutool.core.lang.TypeReference;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Map;
public class Issue3795Test {
@Test
void toBeanTest() {
String fieldMapping = "[{\"lable\":\"id\",\"value\":\"id\"},{\"lable\":\"name\",\"value\":\"name\"},{\"lable\":\"age\",\"value\":\"age\"}]";
Assertions.assertThrows(UnsupportedOperationException.class, ()->{
JSONUtil.toBean(fieldMapping, new TypeReference<Map<String, String>>() {}, false);
});
}
}