JsonObjectUtils { public static MultiMap jsonObjectToMultiMap(JsonObject jsonObject) { CaseInsensitiveHeaders map = new CaseInsensitiveHeaders(); if(jsonObject == null){ return map; } for (Map.Entry<String, Object> stringObjectEntry : jsonObject.getMap().entrySet()) { map.add(stringObjectEntry.getKey(), String.valueOf(stringObjectEntry.getValue())); } return map; } private  JsonObjectUtils(); static JsonObject multiMapToJsonObject(MultiMap map); static MultiMap jsonObjectToMultiMap(JsonObject jsonObject);  }
@Test public void testJsonObjectToMultiMap(TestContext context) { context.assertTrue(JsonObjectUtils.jsonObjectToMultiMap(null).isEmpty()); context.assertTrue(JsonObjectUtils.jsonObjectToMultiMap(new JsonObject()).isEmpty()); JsonObject jso = new JsonObject().put("key_1", "value_1").put("key_2", "value_2"); MultiMap entries = JsonObjectUtils.jsonObjectToMultiMap(jso); context.assertEquals(2, entries.size()); context.assertEquals("value_1", entries.get("key_1")); context.assertEquals("value_2", entries.get("key_2")); JsonObject jso2 = new JsonObject().put("key_1", "value_1").put("key_2", 99).put("key_3", new JsonObject().put("abc", 123)); entries = JsonObjectUtils.jsonObjectToMultiMap(jso2); context.assertEquals(3, entries.size()); context.assertEquals("value_1", entries.get("key_1")); context.assertEquals("99", entries.get("key_2")); context.assertEquals("{\"abc\":123}", entries.get("key_3")); }