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 — loadJSONObject() / Reference

Reference+
Documentation→Reference→Input→Files

Name

loadJSONObject()

Description

Loads a JSON from the data folder or a URL, and returns a JSONObject.

All files loaded and saved by the Processing API use UTF-8 encoding.

Examples

  • // The following short JSON file called "data.json" is parsed 
    // in the code below. It must be in the project's "data" folder.
    
    /*  
      {
        "id": 0,
        "species": "Panthera leo",
       "name": "Lion"
      }
    */
    
    JSONObject json;
    
    void setup() {
    
      json = loadJSONObject("data.json");
    
      int id = json.getInt("id");
      String species = json.getString("species");
      String name = json.getString("name");
    
      println(id + ", " + species + ", " + name);
    }
    
    // Sketch prints:
    // 0, Panthera leo, Lion
    

Syntax

  • loadJSONObject(filename)

Parameters

  • filename(String)name of a file in the data folder or a URL

Return

  • JSONObject

Related

  • JSONObject
  • JSONArray
  • loadJSONArray()
  • saveJSONObject()
  • saveJSONArray()
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.