Java Map to Json mapToJson(Map map)

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

Description

map To Json

License

Open Source License

Declaration

public static String mapToJson(Map<String, String> map) 

Method Source Code


//package com.java2s;

import java.util.Map;

public class Main {
    public static String mapToJson(Map<String, String> map) {
        StringBuffer json = new StringBuffer("{");
        int index = 0;
        for (String key : map.keySet()) {
            if (index > 0) {
                json.append(",");
            }/*  w w  w  . j  a  v a2  s .  c o  m*/

            json.append("'" + key + "':'" + map.get(key) + "'");

            index++;
        }
        json.append("}");
        return json.toString();
    }
}

Related

  1. mapToJson(Map map)
  2. mapToJson(Map map, boolean pretty, String indent)
  3. mapToJson(Map parameters)
  4. toJson(Map map)
  5. toJSON(Map map)
  6. toJSON(Map map)
  7. toJSON(Map map)