public class JsonResponse extends Object
| 构造器和说明 |
|---|
JsonResponse() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
entityToJson(Object obj)
将实体类对象转换为json格式字符串.
|
static String |
entityToJsonFull(Object obj,
String filterPropertyNames)
完整的输出json对象,所有对象只要引用到了都将重复出现。
|
static String |
entityToJsonFullSimple(Object obj,
String filterPropertyNames)
完整的输出json对象,所有对象只要引用到了都将重复出现。
|
static String |
entityToJsonSimple(Object obj)
将实体类对象转换为json格式字符串(不再将驼峰转换为下划线).
|
static String |
error(int code,
String message) |
static String |
error(int code,
String message,
Object obj) |
static String |
success() |
static String |
success(Object obj) |
static String |
success(Object obj,
boolean isRefDetect,
String[] filterPropNames,
boolean isCamelToUnderline)
逻辑上表示成功,组合成需要返回的JSON字符串
|
static String |
success(Object obj,
String[] filterPropNames) |
static String |
successMessage(String message)
如果后台只是想让前台弹出一个成功的提示框,没有别的数据给前台,可以直接使用此函数
前台会有拦截器拦截具有successText字符串的相应
|
static String |
successMessage(String message,
Object data) |
static String |
successMessage(String message,
Object data,
String[] filterPropNames) |
static String |
successWithDate(Object obj,
String dateFormat)
转json 自定义日期类型的转化
|
static String |
toJson(Object obj,
boolean isRefDetect,
String[] filterPropNames,
boolean isCamelToUnderline) |
static String |
toJson(Object obj,
String[] filterPropNames) |
public static String entityToJson(Object obj)
obj - entity实体对象public static String entityToJsonFull(Object obj, String filterPropertyNames)
obj - 需要转换的对象filterPropertyNames - 需要过滤的属性名。以"类名.属性名"的格式出现,也可
以单独制定属性名,则表示所有类的这个属性名都被过滤
这里的属性名为属性开始的名字。多个过滤条件以分号
分割:
a)ModelEntity.belong,ModelEntity类的以belong开始
的属性都不出现在json字串中
b)belong, 所有obj及其关联属性对象中,只要有belong
开始的属性,都不出现在json字串中
c)ModelEntity.belong;createDate,ModelEntity类
的以belong开始的属性,或者以createDate开始的属性,
都不出现在json字串中public static String entityToJsonSimple(Object obj)
obj - entity实体对象public static String entityToJsonFullSimple(Object obj, String filterPropertyNames)
obj - 需要转换的对象filterPropertyNames - 需要过滤的属性名。以"类名.属性名"的格式出现,也可
以单独制定属性名,则表示所有类的这个属性名都被过滤
这里的属性名为属性开始的名字。多个过滤条件以分号
分割:
a)ModelEntity.belong,ModelEntity类的以belong开始
的属性都不出现在json字串中
b)belong, 所有obj及其关联属性对象中,只要有belong
开始的属性,都不出现在json字串中
c)ModelEntity.belong;createDate,ModelEntity类
的以belong开始的属性,或者以createDate开始的属性,
都不出现在json字串中public static String success(Object obj, boolean isRefDetect, String[] filterPropNames, boolean isCamelToUnderline)
obj - 对象isRefDetect - 是否 DisableCircularReferenceDetect。
设置为false则不会带有ref[0]这样的属性值输出,但会有循环引用的风险,需要设置过滤属性名filterPropNames - 过滤属性名的数组isCamelToUnderline - 是否需要将驼峰命名法转换为下划线命名法public static String successWithDate(Object obj, String dateFormat)
obj - dateFormat - public static String success()
public static String toJson(Object obj, boolean isRefDetect, String[] filterPropNames, boolean isCamelToUnderline)
public static String successMessage(String message)
message - 信息提示框的内容Copyright © 2018. All rights reserved.