@Test public void decodesPrimitives() throws IOException { String json = "{\n" + " \"byte\": 32,\n" + " \"boolean\": true,\n" + " \"short\": 100,\n" + " \"int\": 1,\n" + " \"long\": 43,\n" + " \"float\": 23.0,\n" + " \"double\": 3.141592653589793,\n" + " \"char\": \"a\",\n" + " \"String\": \"string\"\n" + "}"; Map<String, Object> map = cartographer.fromJson(json); assertThat(map).hasSize(9) .contains(MapEntry.entry("byte", 32.0)) .contains(MapEntry.entry("boolean", true)) .contains(MapEntry.entry("short", 100.0)) .contains(MapEntry.entry("int", 1.0)) .contains(MapEntry.entry("long", 43.0)) .contains(MapEntry.entry("float", 23.0)) .contains(MapEntry.entry("double", Math.PI)) .contains(MapEntry.entry("char", "a")) .contains(MapEntry.entry("String", "string")); }
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);  }