提交 315d1e31 authored 作者: 宋文杰's avatar 宋文杰

feat(util): add json util class

上级 9189e9d0
package com.elephant.framework.galaxy.aroad.util;
import org.codehaus.jackson.map.ObjectMapper;
import java.util.List;
/**
* @program:
* @description: 序列化工具类
* @author: songwenjie
* @create: 2019-04-23 17:26
**/
public class JsonUtil {
static ObjectMapper objectMapper = new ObjectMapper();
public static String toJson (Object obj) throws Exception{
String json = objectMapper.writeValueAsString(obj);
return json;
}
public static Object toObject (String json) throws Exception{
Object obj = objectMapper.readValue(json, Object.class);
return obj;
}
public static List toList (String json) throws Exception{
List list = objectMapper.readValue(json, List.class);
return list;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论