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

saveJSONObject()

Examples
JSONObject json;

void setup() {

  json = new JSONObject();

  json.setInt("id", 0);
  json.setString("species", "Panthera leo");
  json.setString("name", "Lion");

  saveJSONObject(json, "data/new.json");
}

// Sketch saves the following to a file called "new.json":
// {
//   "id": 0,
//   "species": "Panthera leo",
//   "name": "Lion"
// }
Description Writes the contents of a JSONObject object to a file. By default, this file is saved to the sketch's folder. This folder is opened by selecting "Show Sketch Folder" from the "Sketch" menu.

Alternatively, the file can be saved to any location on the computer by using an absolute path (something that starts with / on Unix and Linux, or a drive letter on Windows).

All files loaded and saved by the Processing API use UTF-8 encoding.
Syntax
saveJSONObject(json, filename)
saveJSONObject(json, filename, options)
Returnsboolean
RelatedJSONObject
JSONArray
loadJSONObject()
loadJSONArray()
saveJSONArray()
Updated on May 19, 2014 05:30:00pm PDT

Creative Commons License