admin管理员组

文章数量:1531692

2024年1月12日发(作者:)

return String(object, config); } /** * 将json转成object * * @param json * @return */ public static Object fromJson(String json) { return (json); } /** * 将json转成对应的对象 * * @param json * @param clazz * @return */ public static T fromJson(String json, Class clazz) { return bject(json, clazz); } /** * 按类型转化 * * @param json * @param type 例: new TypeReference>() {} * @return */ public static T fromJson(String json, TypeReference type) { return bject(json, e()); } /** * 将json转成数组 * * @param json * @return */ public static Object[] toArray(String json) { return toArray(json, null); } /** * 转换为数组 * * @param json * @param clazz * @return */ public static Object[] toArray(String json, Class clazz) { return rray(json, clazz).toArray(); } /** * 转换为List * * @param json * @param clazz * @return */ public static List toList(String json, Class clazz) { return rray(json, clazz); }

} /** * 将javabean转化为序列化的json字符串 * * @param keyvalue * @return */ public static Object beanToJson(Object keyvalue) { String textJson = String(keyvalue); Object objectJson = (textJson); return objectJson; } /** * 将string转化为序列化的json字符串 * * @param json * @return */ public static Object textToJson(String json) { Object objectJson = (json); return objectJson; } /** * json字符串转化为map * * @param json * @return */ public static Map stringToCollect(String json) { return bject(json); } /** * 指定时间格式 的json转换 * * @param object * @param dateFormat * @return */ public static String toJSONStringWithDateFormat(Object object, String dateFormat) { return StringWithDateFormat(object, dateFormat); } /** * 默认时间格式 的json转换 * * @param object * @return */ public static String toJSONStringWithDefaultDateFormat(Object object) { return StringWithDateFormat(object, DEFAULT_DATE_FORMAT); }}5.测试

本文标签: 对象转换格式转化序列化