package com.ozs.mdm.service.util;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author 宋显哲
 * @version 1.0.0 创建于 2017/12/26
 **/
public final class JsonUtil {
    private JsonUtil(){}
    private static ObjectMapper objectMapper = new ObjectMapper();

    public static String toJson(Object obj) throws Exception {
        return objectMapper.writeValueAsString(obj);
    }
    public static <T> T fromJson(String jsonStr,Class<T> clazz) throws Exception {
        return objectMapper.readValue(jsonStr,clazz);
    }
}
