GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — getInt() / Reference

Reference+
Documentation→Reference→Data→Composite→JSONObject

Name

getInt()

Class

JSONObject

Description

Gets the int value associated with the specified key.

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
    

Syntax

  • .getInt(key)
  • .getInt(key, defaultValue)

Parameters

  • key(String)A key string.
  • key(String)A key string.
  • defaultValue(int)The default.

Return

  • int

Related

  • JSONObject::getFloat()
  • JSONObject::getString()
  • JSONObject::getBoolean()
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.