mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -35,7 +35,12 @@ public class Issue1200Test {
|
||||
JSONConfig.of().setIgnoreError(true));
|
||||
|
||||
final ResultBean resultBean = jsonObject.toBean(ResultBean.class);
|
||||
Assertions.assertNull(resultBean.getItems().get(0).get(0));
|
||||
// json对象转ItemsBean,但是字段对应不上,保留空对象
|
||||
Assertions.assertNull(resultBean.getItems().get(0).get(0).get(0).getDetail());
|
||||
|
||||
// 字符串转对象,失败,为null
|
||||
Assertions.assertNull(resultBean.getItems().get(0).get(0).get(1));
|
||||
Assertions.assertNull(resultBean.getItems().get(0).get(0).get(2));
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@@ -21,14 +21,18 @@ import org.dromara.hutool.core.annotation.Alias;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* 兼容下划线模式的JSON转换为驼峰模式<br>
|
||||
* 逻辑见:JSONObjectValueProvider
|
||||
*/
|
||||
public class Issue867Test {
|
||||
|
||||
@Test
|
||||
public void toBeanTest(){
|
||||
public void toBeanTest() {
|
||||
final String jsonStr = "{\"abc_1d\":\"123\",\"abc_d\":\"456\",\"abc_de\":\"789\"}";
|
||||
final JSONObject json = JSONUtil.parseObj(jsonStr);
|
||||
//Console.log(json);
|
||||
final Test02 bean = JSONUtil.toBean(json,Test02.class);
|
||||
final Test02 bean = JSONUtil.toBean(json, Test02.class);
|
||||
Assertions.assertEquals("123", bean.getAbc1d());
|
||||
Assertions.assertEquals("456", bean.getAbcD());
|
||||
Assertions.assertEquals("789", bean.getAbcDe());
|
||||
|
@@ -17,7 +17,7 @@
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
import org.dromara.hutool.json.mapper.JSONValueMapper;
|
||||
import org.dromara.hutool.json.serializer.JSONMapper;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class IssueI9DX5HTest {
|
||||
@Test
|
||||
void xmlToJSONTest() {
|
||||
final String xml = "<GoodMsg>你好</GoodMsg>";
|
||||
final JSONValueMapper mapper = JSONValueMapper.of(JSONConfig.of(), entry -> {
|
||||
final JSONMapper mapper = JSONMapper.of(JSONConfig.of(), entry -> {
|
||||
entry.setKey(StrUtil.toUnderlineCase((CharSequence) entry.getKey()));
|
||||
return true;
|
||||
});
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package org.dromara.hutool.json;
|
||||
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.json.support.JSONStrFormatter;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
Reference in New Issue
Block a user