Java tutorial
//package com.java2s; import java.util.Map; public class Main { public static String mapToJson(Map<String, Object> maps) { StringBuffer sb = new StringBuffer(); int size = maps.size(); int i = 0; sb.append("{"); for (String key : maps.keySet()) { i++; sb.append("\"" + key + "\"" + ":" + "\"" + maps.get(key) + "\""); if (i != size) { sb.append(","); } } sb.append("}"); return sb + ""; } }