Given a Map, add the corresponding JSON to the given JSONObject.

@param jo - JSONObject
@param map - Java Map object
970377
private JSONObject map2JSON(JSONObject jo, Map<String, Object> map) {
        for (Entry<String, Object> entry : map.entrySet()) {
            String subkeys = null;
            String key = null;
            Object value = entry.getValue();
            int i = entry.getKey().indexOf(".");
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "raw key, index", new Object[] { entry.getKey(), i });
            }
            if (i > -1) {
                subkeys = entry.getKey().substring(i + 1);
                key = entry.getKey().substring(0, i);
            } else {
                key = entry.getKey();
            }
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "key, subkeys", new Object[] { key, subkeys });
            }
            if (subkeys == null) { // simple key
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "simple key: " + entry.getKey());
                }
                if (value == null) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "value is null");
                    }
                    jo.put(key, "null");
                } else if (value instanceof Map) { // value is a Map
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "value is a Map, calling map2JSON", value);
                    }
                    jo.put(key, map2JSON(new JSONObject(), (Map<String, Object>) value));
                } else if (value.getClass().isArray()) { // value is an array
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "value is an array, calling array2JSON", value);
                    }
                    jo.put(key, array2JSON(new JSONArray(), (Object[]) value));
                } else { // else value is a "simple" value
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "simple value, adding to jo", value);
                    }
                    jo.put(key, value);
                }
            } else { // compound key
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "compound key: " + entry.getKey());
                }
                JSONObject jsonSubstruc = (JSONObject) jo.get(key);
                if (jsonSubstruc == null) {
                    jsonSubstruc = new JSONObject();
                    jo.put(key, jsonSubstruc);
                }
                Map<String, Object> submap = new TreeMap<String, Object>();
                submap.put(subkeys, value);
                map2JSON(jsonSubstruc, submap);
            }
        }
        return jo;
    }
78848
public void json(String json) {
    if (LogLevel.DEBUG < logConfiguration.logLevel) {
      return;
    }
    printlnInternal(LogLevel.DEBUG, logConfiguration.jsonFormatter.format(json));
  }
343998
Map<String, Object> callForJsonObjectMap(final String host, final int port,
      final String path, final List<Pair<String, String>> paramList) throws IOException {
    final String responseString =
        callForJsonString(host, port, path, paramList);

    @SuppressWarnings("unchecked") final Map<String, Object> jsonResponse =
        (Map<String, Object>) JSONUtils.parseJSONFromString(responseString);
    final String error = (String) jsonResponse.get(ConnectorParams.RESPONSE_ERROR);
    if (error != null) {
      throw new IOException(error);
    }
    return jsonResponse;
  }
1017948
@SuppressWarnings("unchecked")
    public static Map<String, Object> toMap(String json) {
        return (Map<String, Object>) JSON.parse(json);
    }
484704
protected final void mapUpdate(Map map, Object key, Object value) {
        Object o = map.get(key);
        /*
          If a value exists in map.get(key), convert the "value" parameter into
          the type of map.get(key).  It's a best guess as to what the type of the
          Map _should_ be without any further reflective information about the
          types contained in the map.
         */
        if(o != null) {
            Class type = o.getClass();
            value = ParseUtils.convertType(value, type);
        }

        map.put(key, value);
    }
1002844
public void putAllWriteable(BeanMap map) {
        Iterator<String> readableKeys = map.readMethods.keySet().iterator();
        while (readableKeys.hasNext()) {
            String key = readableKeys.next();
            if (getWriteMethod(key) != null) {
                this.put(key, map.get(key));
            }
        }
    }
309474
private void serializeMap(Map<?,?> map, File file) {
        try(ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)))){
            os.writeObject(map);
        } catch (Exception e) {
            logger.error(e.getLocalizedMessage(), e);
        }
    }
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();
    }
973620
public JSONObject put(String key, Collection<?> value) throws JSONException {
		this.put(key, new JSONArray(value));
		return this;
	}
90003
public static void writeStringMap(DataOutputStream os, Map<String,String> map) throws IOException {
		if(map==null) {
			os.writeInt(-1);
		} else {
			Set<Entry<String, String>> es = map.entrySet();
			os.writeInt(es.size());
			for(Entry<String,String> e : es) {
				writeString(os, e.getKey());
				writeString(os, e.getValue());
			}
		}

	}
454924
public void append(Map<?, ?> map) {
		if (map == null || map.size() == 0)
			return;

		for (Map.Entry<?, ?> entry : map.entrySet()) {
			put(StringConverter.toString(entry.getKey()), StringConverter.toNullableString(entry.getValue()));
		}
	}
646688
public JsonWriter property(String key, Map<String, ?> map) throws IOException {
      Preconditions.checkArgument(!inArray(), "Cannot write a property inside an array.");
      writeName(key);
      value(map);
      return this;
   }
320160
@SuppressWarnings("unchecked")
    public static String map2JsonString(Map<String, Object> map)
    {
        IStringBuffer sb = new IStringBuffer();
        sb.append('{');
        for ( Map.Entry<String, Object> entry : map.entrySet() )
        {
            sb.append('"').append(entry.getKey().toString()).append("\": ");
            
            Object obj = entry.getValue();
            if ( obj instanceof List<?> ) {
                sb.append(list2JsonString((List<Object>)obj)).append(',');
            } else if (obj instanceof Object[]) {
                sb.append(vector2JsonString((Object[])obj)).append(',');
            } else if (obj instanceof Map<?,?>) {
                sb.append(map2JsonString((Map<String, Object>)obj)).append(',');
            } else if ((obj instanceof Boolean) 
                    || (obj instanceof Byte) || (obj instanceof Short) 
                    || (obj instanceof Integer) || (obj instanceof Long) 
                    || (obj instanceof Float) || (obj instanceof Double)) {
                sb.append(obj.toString()).append(',');
            } else {
                String v = obj.toString();
                int last = v.length() - 1;
                
                if ( v.length() > 1 
                        && ( (v.charAt(0) == '{' && v.charAt(last) == '}' )
                                || (v.charAt(0) == '[' && v.charAt(last) == ']' ) ) 
                ) {
                    sb.append(v).append(',');
                } else {
                    sb.append('"').append(v).append("\",");
                }
            }
        }
        if ( sb.length() > 1 ) {
            sb.deleteCharAt(sb.length()-1);
        }
        sb.append('}');
        
        return sb.toString();
    }
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();
    }
245330
public static <E> String serialize(Map<String, E> map, Class<E> jsonObjectClass) throws IOException {
        return mapperFor(jsonObjectClass).serialize(map);
    }
713709
private static void mapAdd(Map<String, List<String>> map, String key, String val) {
    List<String> list = map.get(key);
    if (list == null) {
      list = new ArrayList<>();
      map.put(key, list);
    }
    list.add(val);
  }
1293047
private static void setValue(Map<String,String> map, String key, String value) {
		map.put(key,value);
	}