Here you can find the source of toMap(String jsonStr)
public static Map<String, String> toMap(String jsonStr)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, String> toMap(String jsonStr) { Map<String, String> newMap = new HashMap<String, String>(); jsonStr = jsonStr.replace("{", "").replace("}", ""); String[] blocks = jsonStr.split(","); for (int i = 0; i < blocks.length; i++) { String block = blocks[i]; int indexOfCarac = block.indexOf("="); if (indexOfCarac < 0) { continue; }/*from w w w.j a va 2 s . c o m*/ String key = block.substring(0, indexOfCarac).trim(); String value = block.substring(indexOfCarac + 1, block.length()).trim(); newMap.put(key, value); } return newMap; } }