@Test public void encodesNumberMin() throws IOException { StringWriter writer = new StringWriter(); Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("byte", Byte.MIN_VALUE); map.put("short", Short.MIN_VALUE); map.put("int", Integer.MIN_VALUE); map.put("long", Long.MIN_VALUE); map.put("float", Float.MIN_VALUE); map.put("double", Double.MIN_VALUE); map.put("char", Character.MIN_VALUE); cartographer.toJson(map, writer); assertThat(writer.toString()).isEqualTo("{\n" + " \"byte\": -128,\n" + " \"short\": -32768,\n" + " \"int\": -2147483648,\n" + " \"long\": -9223372036854775808,\n" + " \"float\": 1.4E-45,\n" + " \"double\": 4.9E-324,\n" + " \"char\": \"\\u0000\"\n" + "}"); }
public String toJson(Map<?, ?> map) { StringWriter stringWriter = new StringWriter(); try { toJson(map, stringWriter); } catch (IOException e) { throw new AssertionError(e); } return stringWriter.toString(); }
Cartographer { public String toJson(Map<?, ?> map) { StringWriter stringWriter = new StringWriter(); try { toJson(map, stringWriter); } catch (IOException e) { throw new AssertionError(e); } return stringWriter.toString(); } }
Cartographer { public String toJson(Map<?, ?> map) { StringWriter stringWriter = new StringWriter(); try { toJson(map, stringWriter); } catch (IOException e) { throw new AssertionError(e); } return stringWriter.toString(); } Cartographer(boolean isLenient, boolean prettyPrint); }
Cartographer { public String toJson(Map<?, ?> map) { StringWriter stringWriter = new StringWriter(); try { toJson(map, stringWriter); } catch (IOException e) { throw new AssertionError(e); } return stringWriter.toString(); } 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 String toJson(Map<?, ?> map) { StringWriter stringWriter = new StringWriter(); try { toJson(map, stringWriter); } catch (IOException e) { throw new AssertionError(e); } return stringWriter.toString(); } 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);  }