org.json - JSONArray

JSONArray là một chuỗi giá trị có thứ tự. Nó cung cấp các phương thức để truy cập giá trị theo chỉ mục và đặt giá trị. Các loại sau được hỗ trợ:

  • Boolean

  • JSONArray

  • JSONObject

  • Number

  • String

  • Đối tượng JSONObject.NULL

Thí dụ

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);
   }
}

Đầu ra

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