@Test public void encodesNumberMax() throws IOException { StringWriter writer = new StringWriter(); Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("byte", Byte.MAX_VALUE); map.put("short", Short.MAX_VALUE); map.put("int", Integer.MAX_VALUE); map.put("long", Long.MAX_VALUE); map.put("float", Float.MAX_VALUE); map.put("double", Double.MAX_VALUE); map.put("char", Character.MAX_VALUE); cartographer.toJson(map, writer); assertThat(writer.toString()).isEqualTo("{\n" + " \"byte\": 127,\n" + " \"short\": 32767,\n" + " \"int\": 2147483647,\n" + " \"long\": 9223372036854775807,\n" + " \"float\": 3.4028235E38,\n" + " \"double\": 1.7976931348623157E308,\n" + " \"char\": \"\uFFFF\"\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);  }