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.
Name | JSONArray |
||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Examples | String[] species = { "Capra hircus", "Panthera pardus", "Equus zebra" }; String[] names = { "Goat", "Leopard", "Zebra" }; JSONArray values; void setup() { values = new JSONArray(); for (int i = 0; i < species.length; i++) { JSONObject animal = new JSONObject(); animal.setInt("id", i); animal.setString("species", species[i]); animal.setString("name", names[i]); values.setJSONObject(i, animal); } saveJSONArray(values, "data/new.json"); } // Sketch saves the following to a file called "new.json": // [ // { // "id": 0, // "species": "Capra hircus", // "name": "Goat" // }, // { // "id": 1, // "species": "Panthera pardus", // "name": "Leopard" // }, // { // "id": 2, // "species": "Equus zebra", // "name": "Zebra" // } // ] | ||||||||||||||||||||||||||||||||||
Description | A JSONArray stores an array of JSON objects. JSONArrays can be generated from scratch, dynamically, or using data from an existing file. JSON can also be output and saved to disk, as in the example above. | ||||||||||||||||||||||||||||||||||
Methods |
| ||||||||||||||||||||||||||||||||||
Constructor | JSONArray() | ||||||||||||||||||||||||||||||||||
Related | JSONObject loadJSONObject() loadJSONArray() saveJSONObject() saveJSONArray() |