/** * Writes stored name to JSON string. Cleans storage. */ protected void popName() { if (isPushed) { if (pushedComma) { writeComma(); } String name = pushedName; pushedName = null; isPushed = false; writeName(name); } }
@Test void testJsonWriter() { StringBuilder sb = new StringBuilder(); JsonWriter jsonWriter = new JsonWriter(sb, false); jsonWriter.writeOpenObject(); jsonWriter.writeName("one"); jsonWriter.writeNumber(Long.valueOf(123)); jsonWriter.writeComma(); jsonWriter.writeName("two"); jsonWriter.writeString("UberLight"); jsonWriter.writeCloseObject(); assertEquals("{\"one\":123,\"two\":\"UberLight\"}", sb.toString()); } }