@Test public void decodesNestedMaps() throws IOException { String json = "{\n" + " \"a\": {\n" + " \"b\": {\n" + " \"c\": {\n" + " \"d\": {\n" + " \"e\": \"f\"\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}"; Map<String, Object> map = cartographer.fromJson(json); Map<String, Object> expected = ImmutableMap.<String, Object>builder() .put("a", ImmutableMap.<String, Object>builder() .put("b", ImmutableMap.<String, Object>builder() .put("c", ImmutableMap.<String, Object>builder() .put("d", ImmutableMap.<String, Object>builder().put("e", "f").build()) .build()) .build()) .build()) .build(); assertThat(map).isEqualTo(expected); }
public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } Cartographer(boolean isLenient, boolean prettyPrint); }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } Cartographer(boolean isLenient, boolean prettyPrint); Map<String, Object> fromJson(String json); Map<String, Object> fromJson(Reader reader); String toJson(Map<?, ?> map); void toJson(Map<?, ?> map, Writer writer); }
Cartographer { public Map<String, Object> fromJson(String json) throws IOException { if (json == null) { throw new IllegalArgumentException("json == null"); } if (json.length() == 0) { throw new IllegalArgumentException("json empty"); } return fromJson(new StringReader(json)); } Cartographer(boolean isLenient, boolean prettyPrint); Map<String, Object> fromJson(String json); Map<String, Object> fromJson(Reader reader); String toJson(Map<?, ?> map); void toJson(Map<?, ?> map, Writer writer);  }