Java tutorial
//package com.java2s; import java.util.Map; import java.util.Set; public class Main { public static String simpleMapToJsonStr(Map map) { if (map == null || map.isEmpty()) { return "null"; } String jsonStr = "{"; Set<?> keySet = map.keySet(); for (Object key : keySet) { jsonStr += "\"" + key + "\":\"" + map.get(key) + "\","; } jsonStr = jsonStr.substring(0, jsonStr.length() - 1); jsonStr += "}"; return jsonStr; } }