public JsonWriter name(String name) throws IOException { if (current == null || current.array) throw new IllegalStateException("Current item must be an object."); if (!current.needsComma) current.needsComma = true; else writer.write(','); writer.write(outputType.quoteName(name)); writer.write(':'); named = true; return this; }
public JsonWriter array() throws IOException { if (current != null) { if (current.array) { if (!current.needsComma) current.needsComma = true; else writer.write(','); } else { if (!named && !current.array) throw new IllegalStateException("Name must be set."); named = false; } } stack.add(current = new JsonObject(true)); return this; }
public JsonWriter value(Object value) throws IOException { if (current != null) { if (current.array) { if (!current.needsComma) current.needsComma = true; else writer.write(','); } else { if (!named) throw new IllegalStateException("Name must be set."); named = false; } } if (value == null || value instanceof Number || value instanceof Boolean) { writer.write(String.valueOf(value)); } else { writer.write(outputType.quoteValue(value.toString())); } return this; }