JsonWriter implements Closeable { public ObjectWriter<JsonWriter> writeObject() throws IOException { return new ObjectWriter<JsonWriter>(this, true); } JsonWriter(OutputStream os, Charset charset, ObjectMapper mapper); @Override void close(); JsonWriter flush(); JsonWriter newline(); ObjectWriter<JsonWriter> writeObject(); ArrayWriter<JsonWriter> writeArray();  }
@Test public void writeObject() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); JsonWriter writer = writer(os); writer.writeObject() .writeStringField("hello", "world", true) .writeNumberField("missing", 1, false) .done() .close(); assertThat(os.toString(charset.name())).isEqualTo("{\"hello\":\"world\"}"); }