This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Class

JSONArray

Name

append()

Examples
JSONArray json;

void setup() {

  json = new JSONArray();

  json.append(32);
  json.append(1.5);
  json.append("grape");
  json.append(true);

  JSONObject obj = new JSONObject();
  obj.setFloat("persistence", 0.75);
  json.append(obj);

  JSONArray arr = new JSONArray();
  arr.append("red");
  arr.append("green");
  arr.append("blue");
  json.append(arr);

  println(json);
}

// Sketch prints:
// [
//   32,
//   1.5,
//   "grape",
//   true,
//   {"persistence": 0.75},
//   [
//     "red",
//     "green",
//     "blue"
//   ]
// ]
Description Appends a new value to the JSONArray, increasing the array's length by one. New values may be of the following types: int, float, String, boolean, JSONObject, or JSONArray.
Syntax
.append(value)
Parameters
value String: a String value
value int: an int value
value float: a float value
value boolean: a boolean value
value JSONArray: a JSONArray value
value JSONObject: a JSONObject value
ReturnsJSONArray
Relatedsize()
remove()
Updated on May 19, 2014 05:30:03pm PDT

Creative Commons License