Here you can find the source of jsonToObj(String json, Class
public static <T> T jsonToObj(String json, Class<T> clazz)
//package com.java2s; //License from project: Apache License import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { private static final ObjectMapper objectMapper = new ObjectMapper(); public static <T> T jsonToObj(String json, Class<T> clazz) { if (json == null) return null; try {//from w ww .ja v a 2 s .c o m return objectMapper.readValue(json, clazz); } catch (Exception e) { throw new IllegalStateException("Unable to parse Json String.", e); } } /** * for List, Map * * @param json * @param typeReference * @return * @throws Exception */ public static <T> T jsonToObj(String json, TypeReference<T> typeReference) { if (json == null) return null; try { return objectMapper.readValue(json, typeReference); } catch (Exception e) { throw new IllegalStateException("Unable to parse Json String.", e); } } }