Here you can find the source of printMap(Map
public static StringBuilder printMap(Map<String, Object> map)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; public class Main { public static StringBuilder printMap(Map<String, Object> map) { StringBuilder strBuilder = new StringBuilder(); Set<String> keySet = map.keySet(); List<String> keys = new ArrayList<>(keySet); strBuilder.append("{"); for (String key : keys) { strBuilder.append("\"" + key + "\":"); strBuilder.append(map.get(key).toString()); if (!key.equals(keys.get(keys.size() - 1))) { strBuilder.append(","); }//from w ww . j a v a2 s . c om } strBuilder.append("}"); return strBuilder; } }