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 www.processing.org — setJSONObject() / Reference

Reference+
Documentation→Reference→Data→Composite→JSONArray

Name

setJSONObject()

Class

JSONArray

Description

Sets the value of the JSONObject with the index value.

Examples

  • JSONArray json;
    
    void setup() {
    
      json = new JSONArray();
    
      JSONObject lion = new JSONObject();
      lion.setInt("id", 0);
      lion.setString("species", "Panthera leo");
      
      json.setJSONObject(0, lion);
    
      JSONObject zebra = new JSONObject();
      zebra.setInt("id", 1);
      zebra.setString("species", "Equus zebra");
      
      json.setJSONObject(1, zebra);
    
      println(json);
    }
    
    // Sketch prints:
    // [
    //   {
    //     "id": 0,
    //     "species": "Panthera leo"
    //   },
    //   {
    //     "id": 1,
    //     "species": "Equus zebra"
    //   }
    // ]
    

Syntax

  • .setJSONObject(index, value)

Parameters

  • index(int)the index value to target
  • value(JSONObject)the value to assign

Return

  • JSONArray

Related

  • JSONArray::setJSONArray()
  • JSONArray::getJSONObject()
  • JSONArray::getJSONArray()
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.