Map to json string string.

@param map the map
@return the string
421257
public static String mapToJSONString(Map<?, ?> map) {
		if (map == null || map.size() == 0) {
			return "{}";
		}
		StringBuilder sb = new StringBuilder("{");
		for (Object o : map.entrySet()) {
			Entry<?, ?> e = (Entry<?, ?>) o;
			buildAppendString(sb, e.getKey()).append('=');
			buildAppendString(sb, e.getValue()).append(',').append(' ');
		}
		return sb.delete(sb.length() - 2, sb.length()).append('}').toString();
	}
1302669
public static void writeJSON(Map<String, ? extends Object> map, Appendable out, JSONStyle compression)
			throws IOException {
		if (map == null) {
			out.append("null");
			return;
		}
		JsonWriter.JSONMapWriter.writeJSONString(map, out, compression);
	}
633594
public Map<String, Object> jsonStringToMap(String jsonString) {
        if (StringUtils.isEmpty(jsonString)) {
            return null;
        }
        JSONObject jsonObject;
        try {
            jsonObject = new JSONObject(jsonString);
            return jsonObjectToMap(jsonObject);
        } catch (JSONException e) {
            throw new RuntimeException("Unable to convert string to map: " + jsonString, e);
        }
    }
1286612
public String serialize(Map<String, T> map) throws IOException {
        StringWriter sw = new StringWriter();
        JsonGenerator jsonGenerator = LoganSquare.JSON_FACTORY.createGenerator(sw);
        serialize(map, jsonGenerator);
        jsonGenerator.close();
        return sw.toString();
    }
546950
public static <T> String toJson(T t) {
        if (Objects.isNull(t)) {
            log.warn("t is blank. ");
            return "";
        }
        try {
            return OBJECT_MAPPER.writeValueAsString(t);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return "";
        }
    }
6837
public void serialize(Map<String, T> map, JsonGenerator jsonGenerator) throws IOException {
        jsonGenerator.writeStartObject();
        for (Map.Entry<String, T> entry : map.entrySet()) {
            jsonGenerator.writeFieldName(entry.getKey());
            if (entry.getValue() == null) {
                jsonGenerator.writeNull();
            } else {
                serialize(entry.getValue(), jsonGenerator, true);
            }
        }
        jsonGenerator.writeEndObject();
    }
544641
public static JSONObject toJsonObject(Map<String, ?> map) {
    JSONObject jsonObject = new JSONObject();
    for (Map.Entry<String, ?> entry : map.entrySet()) {
      Object value = wrap(entry.getValue());
      try {
        jsonObject.put(entry.getKey(), value);
      } catch (JSONException ignored) {
        // Ignore values that JSONObject doesn't accept.
      }
    }
    return jsonObject;
  }
245330
public static <E> String serialize(Map<String, E> map, Class<E> jsonObjectClass) throws IOException {
        return mapperFor(jsonObjectClass).serialize(map);
    }
1045182
@SuppressWarnings("static-method")
	protected String generateJson(Map<String, Object> map) throws JsonProcessingException {
		final ObjectMapper mapper = new ObjectMapper();
		return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(map);
	}
579914
public static <K extends Comparable<K>, V> String toStringSorted(Map<K, V> map) {
    StringBuilder builder = new StringBuilder();
    toStringSorted(map, builder);
    return builder.toString();
  }
514807
public Map<String, Object> fromJson(String json) throws IOException {
    if (json == null) {
      throw new IllegalArgumentException("json == null");
    }
    if (json.length() == 0) {
      throw new IllegalArgumentException("json empty");
    }
    return fromJson(new StringReader(json));
  }
900439
public static Map<String, String> mapStringToMap(String map) {
    String[] m = map.split("[,;]");
    Map<String, String> res = new HashMap<String, String>();
    for (String str : m) {
      int index = str.lastIndexOf('=');
      String key = str.substring(0, index);
      String val = str.substring(index + 1);
      res.put(key.trim(), val.trim());
    }
    return res;
  }
528665
public static String mapAsJson(Map<String, String> map) {

        JSONObject obj = new JSONObject();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            try {
                obj.put(entry.getKey(), entry.getValue());
            } catch (JSONException e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        return obj.toString();
    }
788838
public static Optional<String> getString(final Map map, final Object... path) {
        return get(map, String.class, path);
    }
1236685
public Map<String, String> getStringMap(final Map<String, String> map) {
		final int len = getVInt();
		for (int i = 0; i < len; i++) {
			map.put(getString(), getString());
		}
		return map;
	}
1096020
public String toJson(Object object) {

		try {
			return mapper.writeValueAsString(object);
		} catch (IOException e) {
			logger.warn("write to json string error:" + object, e);
			return null;
		}
	}
574685
public static String getStr(Map<?, ?> map, Object key) {
		return get(map, key, String.class);
	}