/** * 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 acyclic. * * @return The writer. */ protected Writer write(Writer writer) { return this.write(writer, -1, 0); }
public boolean write(PrintWriter output) { return write(output, null); }
/** * Make a pretty-printed JSON text of this JSONArray. * Warning: This method assumes that the data structure is acyclical. * @param indentFactor The number of spaces to add to each level of * indentation. Use -1 to specify no indentation and no newlines. * @return a printable, displayable, transmittable * representation of the object, beginning * with <code>[</code> <small>(left bracket)</small> and ending * with <code>]</code> <small>(right bracket)</small>. */ public String format(int indentFactor) { StringWriter sw = new StringWriter(); synchronized (sw.getBuffer()) { return this.write(sw, indentFactor, 0).toString(); } }
public boolean save(File file, String options) { PrintWriter writer = PApplet.createWriter(file); boolean success = write(writer, options); writer.close(); return success; }
((JSONObject) value).write(writer, indentFactor, indent); } else if (value instanceof JSONArray) { ((JSONArray) value).write(writer, indentFactor, indent); } else if (value instanceof Map) { new JSONObject((Map) value).write(writer, indentFactor, indent); } else if (value instanceof Collection) { new JSONArray((Collection) value).write(writer, indentFactor, indent); } else if (value.getClass().isArray()) { new JSONArray(value).write(writer, indentFactor, indent); } else if (value instanceof Number) { writer.write(numberToString((Number) value));