### Question:
GatewayMap extends LinkedHashMap<String, Object> { @Override public Object get(Object keyPath) { String[] keys = ((String) keyPath).split("\\."); if (keys.length <= 1) { Matcher m = arrayIndexPattern.matcher(keys[0]); if (!m.matches()) { return super.get(keys[0]); } else { String key = m.group(1); Object o = super.get(key); if (!(o instanceof List)) { throw new IllegalArgumentException("Property '" + key + "' is not an array"); } List<Map<String, Object>> l = (List<Map<String, Object>>) o; Integer index = l.size() - 1; if (!"".equals(m.group(2))) { index = Integer.parseInt(m.group(2)); } return l.get(index); } } Map<String, Object> map = findLastMapInKeyPath((String) keyPath); return map.get(keys[keys.length - 1]); } GatewayMap(int initialCapacity, float loadFactor);  GatewayMap(int initialCapacity);  GatewayMap();  GatewayMap(Map<String, Object> map);  GatewayMap(String jsonMapString);  GatewayMap(String keyPath, Object value); @Override Object put(String keyPath, Object value); GatewayMap set(String keyPath, Object value); @Override Object get(Object keyPath); @Override boolean containsKey(Object keyPath); @Override Object remove(Object keyPath); static Map<String, Object> normalize(Map<String, Object> m);  }### Answer:
@Test public void testJsonConstructorWithMap() { String json = "{\n" + " \"k1\":\"v1\",\n" + " \"k2\":{\n" + " \"k21\": \"v21\",\n" + " \"k22\": \"v22\",\n" + " \"k23\" : {\n" + " \"k231\": \"v231\"\n" + " }\n" + " }\n" + " }"; GatewayMap map = new GatewayMap(json); assertEquals(map.get("k1"), "v1"); assert map.get("k2") instanceof Map; assertEquals(map.get("k2.k21"), "v21"); assertEquals(map.get("k2.k22"), "v22"); assert map.get("k2.k23") instanceof Map; assertEquals(map.get("k2.k23.k231"), "v231"); }
@Test public void keyValueConstructorAddsKey() { assertEquals(new GatewayMap("k1", "v1").get("k1"), "v1"); assertEquals(new GatewayMap("k1.k2", "v12").get("k1.k2"), "v12"); }