Java Map Print printMap(Map map)

Here you can find the source of printMap(Map map)

Description

print Map

License

Open Source License

Declaration

public static StringBuilder printMap(Map<String, Object> map) 

Method Source Code


//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;
    }
}

Related

  1. printMap(Map map)
  2. printMap(Map map)
  3. printMap(Map map)
  4. printMap(Map map)
  5. printMap(Map map)
  6. printMap(Map map, int depth)
  7. printMap(String mapLabel, Map map)
  8. printMapGeneral(Map map)
  9. printMapObject(Map mapobject)