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

com.github.liuzhengyang.simpleapm.agent.util.JsonUtils Maven / Gradle / Ivy

There is a newer version: 1.10.5
Show newest version
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 "";
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy