mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复Pair序列化转换无效问题
This commit is contained in:
@@ -14,20 +14,16 @@ package cn.hutool.json;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.core.lang.TypeReference;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IssueI7GPGXTest {
|
||||
@Test
|
||||
public void toBeanTest() throws NoSuchMethodException {
|
||||
Pair<String, Boolean> hutoolPair = getHutoolPair();
|
||||
String a = JSONUtil.toJsonStr(hutoolPair);
|
||||
System.out.println(a);
|
||||
System.out.println("=====================================");
|
||||
Pair<String, Boolean> pair = JSONUtil.toBean(a, new TypeReference<Pair<String, Boolean>>() {}, false);
|
||||
System.out.println(JSONUtil.toJsonStr(pair));
|
||||
}
|
||||
|
||||
public static Pair<String, Boolean> getHutoolPair() {
|
||||
return new Pair<>("test1", true);
|
||||
@Test
|
||||
public void toBeanTest() {
|
||||
final Pair<String, Boolean> hutoolPair = new Pair<>("test1", true);
|
||||
final String a = JSONUtil.toJsonStr(hutoolPair);
|
||||
final Pair<String, Boolean> pair = JSONUtil.toBean(a, new TypeReference<Pair<String, Boolean>>() {}, false);
|
||||
Assert.assertEquals(hutoolPair, pair);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user