com.github.liuzhengyang.simpleapm.agent.util.JsonUtils Maven / Gradle / Ivy
package com.github.liuzhengyang.simpleapm.agent.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
public class JsonUtils {
public static String toJson(Object o) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
try {
return objectMapper.writeValueAsString(o);
} catch (JsonProcessingException e) {
e.printStackTrace();
return "";
}
}
}