Here you can find the source of json2map(String jsonStr)
public static <T> Map<String, Object> json2map(String jsonStr) throws Exception
//package com.java2s; //License from project: Open Source License import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.HashMap; import java.util.Map; public class Main { private final static ObjectMapper objectMapper = new ObjectMapper(); /**/*w w w. j av a2 s.c om*/ * json string convert to map */ public static <T> Map<String, Object> json2map(String jsonStr) throws Exception { return objectMapper.readValue(jsonStr, Map.class); } /** * json string convert to map with javaBean */ public static <T> Map<String, T> json2map(String jsonStr, Class<T> clazz) throws Exception { Map<String, Map<String, Object>> map = objectMapper.readValue(jsonStr, new TypeReference<Map<String, T>>() { }); Map<String, T> result = new HashMap<String, T>(); for (Map.Entry<String, Map<String, Object>> entry : map.entrySet()) { result.put(entry.getKey(), map2pojo(entry.getValue(), clazz)); } return result; } /** * map convert to javaBean */ public static <T> T map2pojo(Map map, Class<T> clazz) { return objectMapper.convertValue(map, clazz); } }