### Question:
JsonUtils { public static AwsJsonWriter getJsonWriter(Writer out) { return FACTORY.getJsonWriter(out); }  @Deprecated static void setJsonEngine(JsonEngine jsonEngine); static AwsJsonReader getJsonReader(Reader in); static AwsJsonWriter getJsonWriter(Writer out); @SuppressWarnings("unchecked") static Map<String, String> jsonToMap(Reader in); @SuppressWarnings("unchecked") static Map<String, String> jsonToMap(String json); @SuppressWarnings("unchecked") static Map<String, String> jsonToStringMapWithList(Reader in); static String mapToString(Map<String, String> map);  }### Answer:
@Test public void testJsonWriter() throws IOException { StringWriter out = new StringWriter(); AwsJsonWriter writer = JsonUtils.getJsonWriter(out); writer.beginObject() .name("string").value("string") .name("long").value(123) .name("double").value(123.45) .name("null").value() .name("true").value(true) .name("false").value(false) .name("encoding").value("Chloë") .name("array").beginArray() .value("string").value(123).value(123.45).value().value(true).value(false) .endArray() .name("object").beginObject().endObject() .endObject().close(); String json = out.toString(); assertEquals("same json", JSON_STRING, json); }
@Test public void testDate() throws IOException { Date d = new Date(1423875641895L); String target = "1423875641.895"; StringWriter out = new StringWriter(); JsonUtils.getJsonWriter(out) .beginArray().value(d).endArray() .close(); assertEquals("[" + target + "]", out.toString()); out.getBuffer().setLength(0); }
@Test public void testByteBuffer() throws IOException { ByteBuffer bb = generateByteBuffer(16); String target = "AAECAwQFBgcICQoLDA0ODw=="; StringWriter out = new StringWriter(); JsonUtils.getJsonWriter(out) .beginArray().value(bb).endArray() .close(); assertEquals("[\"" + target + "\"]", out.toString()); out.getBuffer().setLength(0); }