com.cisco.oss.foundation.logging.transactions.JsonUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of logging-log4j Show documentation
Show all versions of logging-log4j Show documentation
This project is the logging log4j implementation library in the cisco vss foundation runtime
package com.cisco.oss.foundation.logging.transactions;
import java.io.StringWriter;
import java.io.Writer;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
public class JsonUtil {
private static ObjectMapper mapper;
static {
mapper = new ObjectMapper();
mapper.setSerializationInclusion(Inclusion.NON_EMPTY);
}
public static String getObjectAsJson(Object object) {
Writer strWriter = new StringWriter();
try {
mapper.writeValue(strWriter, object);
return strWriter.toString();
} catch(Exception e) {
return null;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy