add testcase

This commit is contained in:
shaojin.wensj 2022-06-03 17:37:18 +08:00
parent da3b4ac95d
commit bc70e12e9a
2 changed files with 15 additions and 1 deletions

View File

@ -67,7 +67,21 @@ public class SmartMatchTest {
assertEquals(123, bean.userId);
}
@Test
public void test5() {
String str = "[{\"user-id\":123,\"item\":{\"item_id\":201}}]";
JSONArray array = JSON.parseArray(str);
Bean bean = array.getObject(0, Bean.class);
assertEquals(123, bean.userId);
assertEquals(201, bean.item.itemId);
}
public static class Bean {
public int userId;
public Item item;
}
public static class Item {
public int itemId;
}
}

View File

@ -25,7 +25,7 @@ public class Issue402 {
@Test
public void test1() {
JSONArray jsonArray = JSON.parseArray(str);
DeptTreeJson test = jsonArray.getObject(0, DeptTreeJson.class, JSONReader.Feature.SupportSmartMatch);
DeptTreeJson test = jsonArray.getObject(0, DeptTreeJson.class);
assertEquals("测试公司", test.getDeptName());
}