@Test public void serializeMap() throws Exception { final HashMap<String, Object> map = new HashMap<String, Object>(); map.put("foo", "bar"); map.put("foo2", 1.0); map.put("foo3", false); map.put("foo4", Arrays.asList(1.0, "foo", null, true, false, "bar")); verifyRoundTrip(map); }
private void serializeMap(Map<Object, Object> map, int indentation) { writer.print("{"); String comma = ""; for (Map.Entry<Object, Object> value : map.entrySet()) { writer.println(comma); indent(indentation + 1); writer.print("\""); writer.print(value.getKey().toString()); writer.print("\": "); serialize(value.getValue(), indentation + 1); comma = ","; } writer.println(); indent(indentation); writer.print("}"); }
JsonWriter { private void serializeMap(Map<Object, Object> map, int indentation) { writer.print("{"); String comma = ""; for (Map.Entry<Object, Object> value : map.entrySet()) { writer.println(comma); indent(indentation + 1); writer.print("\""); writer.print(value.getKey().toString()); writer.print("\": "); serialize(value.getValue(), indentation + 1); comma = ","; } writer.println(); indent(indentation); writer.print("}"); } }
JsonWriter { private void serializeMap(Map<Object, Object> map, int indentation) { writer.print("{"); String comma = ""; for (Map.Entry<Object, Object> value : map.entrySet()) { writer.println(comma); indent(indentation + 1); writer.print("\""); writer.print(value.getKey().toString()); writer.print("\": "); serialize(value.getValue(), indentation + 1); comma = ","; } writer.println(); indent(indentation); writer.print("}"); } JsonWriter(OutputStream outputStream); }
JsonWriter { private void serializeMap(Map<Object, Object> map, int indentation) { writer.print("{"); String comma = ""; for (Map.Entry<Object, Object> value : map.entrySet()) { writer.println(comma); indent(indentation + 1); writer.print("\""); writer.print(value.getKey().toString()); writer.print("\": "); serialize(value.getValue(), indentation + 1); comma = ","; } writer.println(); indent(indentation); writer.print("}"); } JsonWriter(OutputStream outputStream);  }
JsonWriter { private void serializeMap(Map<Object, Object> map, int indentation) { writer.print("{"); String comma = ""; for (Map.Entry<Object, Object> value : map.entrySet()) { writer.println(comma); indent(indentation + 1); writer.print("\""); writer.print(value.getKey().toString()); writer.print("\": "); serialize(value.getValue(), indentation + 1); comma = ","; } writer.println(); indent(indentation); writer.print("}"); } JsonWriter(OutputStream outputStream);   }