/** Writes a null value */ public JSONWriter value() throws IOException { write("null"); return this; }
/** Called on the start of a field or array value */ private void beginFieldOrArrayValue() throws IOException { if (needsComma.getFirst()) { write(","); } }
/** Begin an object value */ public JSONWriter beginObject() throws IOException { write("{"); needsComma.addFirst(Boolean.FALSE); return this; }
/** End an object value */ public JSONWriter endObject() throws IOException { write("}"); needsComma.removeFirst(); return this; }
/** End an array value */ public JSONWriter endArray() throws IOException { write("]"); needsComma.removeFirst(); return this; }
/** Begin an array value */ public JSONWriter beginArray() throws IOException { write("["); needsComma.addFirst(Boolean.FALSE); return this; }
/** Writes a numeric value */ public JSONWriter value(Number value) throws IOException { write(value.toString()); return this; }
/** Writes a boolean value */ public JSONWriter value(boolean value) throws IOException { write(Boolean.toString(value)); return this; }
/** Begins an object field */ public JSONWriter beginField(String fieldName) throws IOException { beginFieldOrArrayValue(); write("\"" + fieldName + "\":"); return this; }