操作日志逻辑及结构实现调整
This commit is contained in:
@@ -2,27 +2,42 @@ package com.gzzn.omms.adminapi.utils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
|
||||
public class JsonUtil {
|
||||
public static String getString(Object object) throws JsonProcessingException
|
||||
private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
|
||||
|
||||
public static String getString(Object object)
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
|
||||
java.lang.String jsonStr = ow.writeValueAsString(object);
|
||||
java.lang.String jsonStr = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
|
||||
jsonStr = ow.writeValueAsString(object);
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error("获取json串异常:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return jsonStr;
|
||||
}
|
||||
|
||||
|
||||
public static <T> T getObject(String str,Class<T> valueType) throws JsonParseException, JsonMappingException, IOException
|
||||
public static <T> T getObject(String str,Class<T> valueType)
|
||||
{
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
T obj = mapper.readValue(str, valueType);
|
||||
T obj = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
obj = mapper.readValue(str, valueType);
|
||||
} catch (IOException e) {
|
||||
logger.error("json转为Class异常:", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user