JSONArray ja = new JSONArray(); ja.put("11"); ja.put("22"); ja.put("33"); JSONArray ja2 = new JSONArray(); ja2.put("aa"); ja2.put("bb"); ja.put(ja2); System.out.println(ja.toString()); // jsonarray 這個表明集合 左右兩邊[] // ["11","22","33",["aa","bb"]] JSONObject jsonObject = new JSONObject(); try { jsonObject.put("aaa", "111"); jsonObject.put("bbb", "222"); jsonObject.put("ccc", "333"); jsonObject.put("ddd", "444"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(jsonObject.toString()); // jsonObject就是中間有個:號,而後左右兩邊是{} // {"ddd":"444","ccc":"333","bbb":"222","aaa":"111"}