/** * 将list对象转换为json格式的数据 * * @param totalNum,记录总数 * @param inList,需要转换的list * @return */ public static String getJsonFromList(Boolean b, String msg, Object obj) { Map<String, Object> map = new HashMap<String, Object>(); map.put(SUCCESS, b); map.put(MESSAGE, msg); map.put(OBJECT, obj); return DateJsonValueProcessor.map2JSonStr(map); }
/** * 将单个对象转换为json格式,此对象不能为集合类型 * * @param inObject * @return */ public static String getJsonFromObject(Object inObject) { JSONObject jsonString = DateJsonValueProcessor.obj2JsonObj(inObject); return jsonString.toString(); }
/** * 将list对象转换为json格式的数据 * * @param totalNum,记录总数 * @param inList,需要转换的list * @return */ public static String getJsonFromList(long totalNum, List inList) { Map<String, Object> map = new HashMap<String, Object>(); map.put(TOTAL, totalNum); map.put(RECORDS, inList); return DateJsonValueProcessor.map2JSonStr(map); }