All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cisco.oss.foundation.logging.transactions.JsonUtil Maven / Gradle / Ivy

Go to download

This project is the logging log4j implementation library in the cisco vss foundation runtime

There is a newer version: 1.2.1-2
Show newest version
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