- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

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 | JSONObject
Name | ### getFloat()
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 float value associated with the specified key.
Syntax |
    .getFloat(key)
    .getFloat(key, defaultValue)
Parameters |
key | String: a key string
Returns | float
Related | getInt() getString() getBoolean()

Updated on January 1, 2021 03:38:09am EST
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.