|
@@ -89,7 +89,8 @@ public class MapUtil {
|
|
|
jsonArray.put(item);
|
|
|
}
|
|
|
}
|
|
|
- json.put(fieldName, jsonArray);
|
|
|
+ json.set(fieldName, jsonArray);
|
|
|
+// json.put(fieldName, jsonArray);
|
|
|
} else if (Map.class.isAssignableFrom(field.getType())) {
|
|
|
// 字段是Map类型
|
|
|
Map<?, ?> map = (Map<?, ?>) fieldValue;
|
|
@@ -99,13 +100,16 @@ public class MapUtil {
|
|
|
Object value = entry.getValue();
|
|
|
if (value instanceof Object) {
|
|
|
// 如果Map的值是实体类对象,则递归转换
|
|
|
- jsonMap.put(key.toString(), convertEntityToJson(value));
|
|
|
+ jsonMap.set(key.toString(), convertEntityToJson(value));
|
|
|
+// jsonMap.put(key.toString(), convertEntityToJson(value));
|
|
|
} else {
|
|
|
// 否则直接添加到Map中
|
|
|
- jsonMap.put(key.toString(), value);
|
|
|
+ jsonMap.set(key.toString(), value);
|
|
|
+// jsonMap.put(key.toString(), value);
|
|
|
}
|
|
|
}
|
|
|
- json.put(fieldName, jsonMap);
|
|
|
+ json.set(fieldName, jsonMap);
|
|
|
+// json.put(fieldName, jsonMap);
|
|
|
} else if (
|
|
|
String.class.isAssignableFrom(field.getType()) ||
|
|
|
Integer.class.isAssignableFrom(field.getType()) ||
|
|
@@ -119,11 +123,13 @@ public class MapUtil {
|
|
|
field.getType().isArray()
|
|
|
) {
|
|
|
// 判断不了实体类,只能判断上面的通用类型,适合类型的直接输出
|
|
|
- json.put(fieldName, fieldValue);
|
|
|
+ json.set(fieldName, fieldValue);
|
|
|
+// json.put(fieldName, fieldValue);
|
|
|
} else {
|
|
|
// 无法识别实体类类型 else if (field.getType().isAssignableFrom(Entity.class)
|
|
|
// 字段是实体类的实例,递归转换
|
|
|
- json.put(fieldName, convertEntityToJson(fieldValue));
|
|
|
+ json.set(fieldName, convertEntityToJson(fieldValue));
|
|
|
+// json.put(fieldName, convertEntityToJson(fieldValue));
|
|
|
}
|
|
|
}
|
|
|
}
|