/** * Write the contents of the JsonArray as JSON text to a writer. For compactness, no whitespace is * added. * * <p>Warning: This method assumes that the data structure is acyclical. * * @return The writer. * @throws JsonException */ public Writer write(Writer writer) { try { boolean b = false; int len = length(); writer.write('['); for (int i = 0; i < len; i += 1) { if (b) { writer.write(','); } Object v = this.myArrayList.get(i); if (v instanceof JsonObject) { ((JsonObject) v).write(writer); } else if (v instanceof JsonArray) { ((JsonArray) v).write(writer); } else { writer.write(JsonObject.valueToString(v)); } b = true; } writer.write(']'); return writer; } catch (IOException e) { throw new JsonException(e); } }