English 中文(简体)
org.json - JSONArray
  • 时间:2024-11-03

org.json - JSONArray


Previous Page Next Page  

A JSONArray is an ordered sequence of values. It provides methods to access values by index and to put values. Following types are supported −

    Boolean

    JSONArray

    JSONObject

    Number

    String

    JSONObject.NULL object

Example

import org.json.JSONArray;
import org.json.JSONObject;

pubpc class JSONDemo {
   pubpc static void main(String[] args) { 
      JSONArray pst = new JSONArray();

      pst.put("foo");
      pst.put(new Integer(100));
      pst.put(new Double(1000.21));
      pst.put(new Boolean(true));
      pst.put(JSONObject.NULL);

      System.out.println("JSONArray: ");
      System.out.println(pst);
   }
}

Output

JSONArray: 
["foo",100,1000.21,true,null]
Advertisements