diff --git a/UPDATE.md b/UPDATE.md index 15fd707..4be0bb5 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -1,6 +1,12 @@ yexuejc-base 更新记录 ------------------ +#### version :1.3.4 +**time:2019-1-2 20:32:12**
+**branch:** master
+**update:**
+>1. objUtil list类型修复 +# #### version :1.3.3 **time:2019-1-2 14:06:47**
**branch:** master
diff --git a/pom.xml b/pom.xml index 3b2f3e0..6bd77e8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ top.yexuejc yexuejc-base - 1.3.3 + 1.3.4 ${project.artifactId} https://github.com/yexuejc/yexuejc-base diff --git a/src/main/java/com/yexuejc/base/util/ObjUtil.java b/src/main/java/com/yexuejc/base/util/ObjUtil.java index b98c753..c2f3bee 100644 --- a/src/main/java/com/yexuejc/base/util/ObjUtil.java +++ b/src/main/java/com/yexuejc/base/util/ObjUtil.java @@ -121,6 +121,18 @@ public class ObjUtil { continue; } objMap.put(fName, f.get(obj)); + } else if (o instanceof List) { + List list = (List) o; + List bodyList = new ArrayList(); + list.forEach(it -> { + if (null != it) { + Map underlineMap = getUnderlineMap(it, isAnnotationAll, putNull); + bodyList.add(underlineMap); + } + }); + if (bodyList.size() > 0) { + objMap.put(fName, bodyList); + } } else { Map underlineMap = getUnderlineMap(o, isAnnotationAll, putNull); objMap.put(fName, underlineMap); @@ -141,8 +153,11 @@ public class ObjUtil { a.setaM1("method1"); a.setbM1("b1Mthod1"); a.protectedStr = "protectedStr"; - a.c = new C(); - a.c.ageInt = "test"; + C c = new C(); + c.ageInt = "test"; + a.c = c; + a.list = new ArrayList<>(); + a.list.add(c); Map underlineMap = getUnderlineMap(a, false, false); System.out.println(JsonUtil.obj2Json(underlineMap)); } @@ -170,6 +185,7 @@ public class ObjUtil { public String testAss; private String bM1; private C c; + List list; public String getbM1() { return bM1;