Browse Source

jfinal 4.9

James 5 years ago
parent
commit
9163443849
1 changed files with 15 additions and 15 deletions
  1. 15 15
      src/main/java/com/jfinal/json/JFinalJson.java

+ 15 - 15
src/main/java/com/jfinal/json/JFinalJson.java

@@ -302,35 +302,35 @@ public class JFinalJson extends Json {
 		Map map = new HashMap();
 		Method[] methods = model.getClass().getMethods();
 		for (Method m : methods) {
+			if (m.getParameterCount() != 0) {
+				continue ;
+			}
+			
 			String methodName = m.getName();
 			int indexOfGet = methodName.indexOf("get");
 			if (indexOfGet == 0 && methodName.length() > 3) {	// Only getter
 				String attrName = methodName.substring(3);
 				if (!attrName.equals("Class")) {				// Ignore Object.getClass()
-					if (m.getParameterCount() == 0) {
 						try {
 							Object value = m.invoke(model);
 							map.put(StrKit.firstCharToLowerCase(attrName), value);
 						} catch (Exception e) {
 							throw new RuntimeException(e.getMessage(), e);
 						}
-					}
 				}
 			}
 			else {
-               int indexOfIs = methodName.indexOf("is");
-               if (indexOfIs == 0 && methodName.length() > 2) {
-                  String attrName = methodName.substring(2);
-                  if (m.getParameterCount() == 0) {
-                      try {
-                          Object value = m.invoke(model);
-                          map.put(StrKit.firstCharToLowerCase(attrName), value);
-                      } catch (Exception e) {
-                          throw new RuntimeException(e.getMessage(), e);
-                      }
-                  }
-               }
-            }
+				int indexOfIs = methodName.indexOf("is");
+				if (indexOfIs == 0 && methodName.length() > 2) {
+					String attrName = methodName.substring(2);
+					try {
+						Object value = m.invoke(model);
+						map.put(StrKit.firstCharToLowerCase(attrName), value);
+					} catch (Exception e) {
+						throw new RuntimeException(e.getMessage(), e);
+					}
+				}
+			}
 		}
 		return mapToJson(map, depth);
 	}