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 | ### 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
Returns | JSONArray
Related | setJSONArray() getJSONObject() getJSONArray()

Updated on May 19, 2014 05:30:03pm PDT