@Test public void testToMapWith() throws Exception { JSONObject json = new JSONObject(); json.put("boolean", true); json.put("string", "String"); json.put("double", 1.3); Map<String, String> map = JSONUtils.toMap(json); assertEquals("true", map.get("boolean")); assertEquals("String", map.get("string")); assertEquals("1.3", map.get("double")); }
public static Map<String, String> toMap(JSONObject json) { if (json == null) return Collections.emptyMap(); HashMap<String, String> map = new HashMap<String, String>(); for (Iterator<String> iterator = json.keys(); iterator.hasNext();) { String key = iterator.next(); map.put(key, json.optString(key)); } return map; }
JSONUtils { public static Map<String, String> toMap(JSONObject json) { if (json == null) return Collections.emptyMap(); HashMap<String, String> map = new HashMap<String, String>(); for (Iterator<String> iterator = json.keys(); iterator.hasNext();) { String key = iterator.next(); map.put(key, json.optString(key)); } return map; } }
JSONUtils { public static Map<String, String> toMap(JSONObject json) { if (json == null) return Collections.emptyMap(); HashMap<String, String> map = new HashMap<String, String>(); for (Iterator<String> iterator = json.keys(); iterator.hasNext();) { String key = iterator.next(); map.put(key, json.optString(key)); } return map; } private  JSONUtils(); }
JSONUtils { public static Map<String, String> toMap(JSONObject json) { if (json == null) return Collections.emptyMap(); HashMap<String, String> map = new HashMap<String, String>(); for (Iterator<String> iterator = json.keys(); iterator.hasNext();) { String key = iterator.next(); map.put(key, json.optString(key)); } return map; } private  JSONUtils(); static JObject mapToJSON(Map<String, String> map); static JValue setToJSON(Set<String> set); static JValue filtersToJSON(ResourceListQuery query, ListProvidersService listProvidersService,
          Organization org); static JValue filtersToJSONSeriesWriteAccess(ResourceListQuery query, ListProvidersService listProvidersService,
          Organization org, Map<String, String> series); static JSONObject fromMap(Map<String, String> map); static Map<String, String> toMap(JSONObject json); }
JSONUtils { public static Map<String, String> toMap(JSONObject json) { if (json == null) return Collections.emptyMap(); HashMap<String, String> map = new HashMap<String, String>(); for (Iterator<String> iterator = json.keys(); iterator.hasNext();) { String key = iterator.next(); map.put(key, json.optString(key)); } return map; } private  JSONUtils(); static JObject mapToJSON(Map<String, String> map); static JValue setToJSON(Set<String> set); static JValue filtersToJSON(ResourceListQuery query, ListProvidersService listProvidersService,
          Organization org); static JValue filtersToJSONSeriesWriteAccess(ResourceListQuery query, ListProvidersService listProvidersService,
          Organization org, Map<String, String> series); static JSONObject fromMap(Map<String, String> map); static Map<String, String> toMap(JSONObject json);  }