org.json - JSONArray



JSONArray 是一個有序序列值。它提供根據索引獲取值和插入值的方法。支援下列型別 −

  • 布林

  • JSONArray

  • JSONObject

  • 數字

  • 字串

  • JSONObject.NULL 物件

示例

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

輸出

JSONArray: 
["foo",100,1000.21,true,null]
廣告
© . All rights reserved.