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 | JSONObject
Name | ### getInt()
Examples |
    // The following short JSON file called "data.json" is parsed
    // in the code below. It must be in the project's "data" folder.
    //
    // {
    //   "count": 32,
    //   "weight": 1.13,
    //   "name": "grape",
    //   "isFruit": true
    // }

    JSONObject json;

    void setup() {

      json = loadJSONObject("data.json");

      int count = json.getInt("count");
      float weight = json.getFloat("weight");
      String name = json.getString("name");
      boolean isFruit = json.getBoolean("isFruit");

      println(count + ", " + weight + ", " + name + ", " + isFruit);
    }

    // Sketch prints:
    // 32, 1.13, grape, true
Description | Gets the int value associated with the specified key.
Syntax |
    .getInt(key)
    .getInt(key, defaultValue)
Parameters |
key | String: a key string
key | String: A key string.
defaultValue | int: The default.
Returns | int
Related | getFloat() getString() getBoolean()

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