org.json - JSONArray
Ein JSONArray ist eine geordnete Folge von Werten. Es bietet Methoden, um auf Werte per Index zuzugreifen und Werte zu setzen. Folgende Typen werden unterstützt -
Boolean
JSONArray
JSONObject
Number
String
JSONObject.NULL-Objekt
Beispiel
import org.json.JSONArray;
import org.json.JSONObject;
public class JSONDemo {
public static void main(String[] args) {
JSONArray list = new JSONArray();
list.put("foo");
list.put(new Integer(100));
list.put(new Double(1000.21));
list.put(new Boolean(true));
list.put(JSONObject.NULL);
System.out.println("JSONArray: ");
System.out.println(list);
}
}
Ausgabe
JSONArray:
["foo",100,1000.21,true,null]