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

Class

JSONArray

Name

setJSONObject()

Examples
JSONArray json;

void setup() {

  json = new JSONArray();

  JSONObject lion = new JSONObject();
  lion.setInt("id", 0);
  lion.setString("species", "Panthera leo");
  
  json.setJSONObject(0, lion);

  JSONObject zebra = new JSONObject();
  zebra.setInt("id", 1);
  zebra.setString("species", "Equus zebra");
  
  json.setJSONObject(1, zebra);

  println(json);
}

// Sketch prints:
// [
//   {
//     "id": 0,
//     "species": "Panthera leo"
//   },
//   {
//     "id": 1,
//     "species": "Equus zebra"
//   }
// ]
Description Sets the value of the JSONObject with the index value.
Syntax
.setJSONObject(index, value)
Parameters
index int: the index value to target
value JSONObject: the value to assign
ReturnsJSONArray
RelatedsetJSONArray()
getJSONObject()
getJSONArray()
Updated on January 1, 2021 03:38:09am EST