mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix bug
This commit is contained in:
parent
dde6b356ef
commit
d3f29fad02
@ -115,17 +115,6 @@ public class MapToBeanCopier<T> extends AbsCopier<Map<?, ?>, T> {
|
|||||||
// 转驼峰尝试查找
|
// 转驼峰尝试查找
|
||||||
sKeyStr = StrUtil.toCamelCase(sKeyStr);
|
sKeyStr = StrUtil.toCamelCase(sKeyStr);
|
||||||
propDesc = targetPropDescMap.get(sKeyStr);
|
propDesc = targetPropDescMap.get(sKeyStr);
|
||||||
if(null != propDesc){
|
|
||||||
return propDesc;
|
return propDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// boolean类型参数名转换尝试查找
|
|
||||||
if(sKeyStr.startsWith("is")){
|
|
||||||
sKeyStr = StrUtil.removePreAndLowerFirst(sKeyStr, 2);
|
|
||||||
propDesc = targetPropDescMap.get(sKeyStr);
|
|
||||||
return propDesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -261,8 +261,11 @@ public class BeanUtilTest {
|
|||||||
|
|
||||||
final SubPersonWithAlias subPersonWithAlias = BeanUtil.toBean(map, SubPersonWithAlias.class);
|
final SubPersonWithAlias subPersonWithAlias = BeanUtil.toBean(map, SubPersonWithAlias.class);
|
||||||
Assert.assertEquals("sub名字", subPersonWithAlias.getSubName());
|
Assert.assertEquals("sub名字", subPersonWithAlias.getSubName());
|
||||||
Assert.assertTrue(subPersonWithAlias.isBooleana());
|
|
||||||
Assert.assertEquals(true, subPersonWithAlias.getBooleanb());
|
// https://gitee.com/dromara/hutool/issues/I6H0XF
|
||||||
|
// is_booleana并不匹配booleana字段
|
||||||
|
Assert.assertFalse(subPersonWithAlias.isBooleana());
|
||||||
|
Assert.assertNull(subPersonWithAlias.getBooleanb());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.hutool.json;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class IssueI6H0XFTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void toBeanTest(){
|
||||||
|
final Demo demo = JSONUtil.toBean("{\"biz\":\"A\",\"isBiz\":true}", Demo.class);
|
||||||
|
Assert.assertEquals("A", demo.getBiz());
|
||||||
|
Assert.assertEquals("{\"biz\":\"A\"}", JSONUtil.toJsonStr(demo));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
static class Demo {
|
||||||
|
String biz;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user