Here you can find the source of stringToMap(String value)
public static Map stringToMap(String value) throws Exception
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { public static Map stringToMap(String value) throws Exception { if (value == null || value.length() == 0) throw new Exception(); if (value.startsWith("{") || value.startsWith("[")) value = value.substring(1);//from w ww.j ava 2 s.c o m if (value.endsWith("}") || value.endsWith("]")) value = value.substring(0, value.length() - 1); String[] elements = value.split(","); Map<String, String> map = new HashMap(); for (int index = 0; index < elements.length; index++) { String[] pair = elements[index].split(":"); map.put(pair[0], pair[1]); } return map; } }