import com.fasterxml.jackson.core.type.TypeReference;

import com.fasterxml.jackson.databind.ObjectMapper;

 

private final static ObjectMapper objectMapper = new ObjectMapper();

 

/**
 *
 * 어떤 특정한 Json String 값을 TypeReference<T>로 번형
 *
 * @param HttpServletRequest request, String jsonKey, TypeReference<T> typeReference
 * @return Map<String, Object>
 * @throws Exception
 **/

public static <T> T convertJsonToObject(String jsonStr, TypeReference<T> typeReference) throws Exception {
    return objectMapper.readValue(jsonStr, typeReference);

}

+ Recent posts