mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -20,6 +20,7 @@ public class Issue1075Test {
|
||||
public void testToBeanIgnoreCase() {
|
||||
// 在忽略大小写的情况下,f2、fac都匹配
|
||||
ObjA o2 = JSONUtil.parseObj(jsonStr, JSONConfig.create().setIgnoreCase(true)).toBean(ObjA.class);
|
||||
|
||||
Assert.assertEquals("fac", o2.getFAC());
|
||||
Assert.assertEquals("f2", o2.getF2());
|
||||
}
|
||||
|
@@ -27,10 +27,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class JSONArrayTest {
|
||||
|
||||
@Test(expected = JSONException.class)
|
||||
public void createJSONArrayTest(){
|
||||
// 集合类不支持转为JSONObject
|
||||
new JSONArray(new JSONObject(), JSONConfig.create());
|
||||
@Test()
|
||||
public void createJSONArrayFromJSONObjectTest(){
|
||||
// JSONObject实现了Iterable接口,可以转换为JSONArray
|
||||
final JSONObject jsonObject = new JSONObject();
|
||||
|
||||
JSONArray jsonArray = new JSONArray(jsonObject, JSONConfig.create());
|
||||
Assert.assertEquals(new JSONArray(), jsonArray);
|
||||
|
||||
jsonObject.set("key1", "value1");
|
||||
jsonArray = new JSONArray(jsonObject, JSONConfig.create());
|
||||
Assert.assertEquals(1, jsonArray.size());
|
||||
Assert.assertEquals("[{\"key1\":\"value1\"}]", jsonArray.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +136,7 @@ public class JSONArrayTest {
|
||||
public void toDictListTest() {
|
||||
String jsonArr = "[{\"id\":111,\"name\":\"test1\"},{\"id\":112,\"name\":\"test2\"}]";
|
||||
|
||||
JSONArray array = JSONUtil.parseArray(jsonArr);
|
||||
JSONArray array = JSONUtil.parseArray(jsonArr, JSONConfig.create().setIgnoreError(false));
|
||||
|
||||
List<Dict> list = JSONUtil.toList(array, Dict.class);
|
||||
|
||||
|
Reference in New Issue
Block a user