package com.xt.hb.data.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Json工具类
 * 
 * @author 袁晓冬
 *
 */
public class JsonUtils {
    private static final Logger log = LoggerFactory.getLogger(JsonUtils.class);

    /**
     * 命名内容转换为JSON字符串
     * 
     * @return
     */
    public String toJsonString(Object value) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            return mapper.writeValueAsString(value);
        }
        catch (JsonProcessingException e) {
            log.error("Json processing exception:" + e.getMessage());
        }
        return null;
    }
}
