package com.ozs.da.utils;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author 许明
 * on 2019/3/5.
 * @version 2.0.0
 */
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);
    }
}
