我想從對象打印這樣的:如何打印對象數組中的JAVA
{"data":[["Tiger Nixon","System
Architect","Edinburgh","5421","2011\/04\/25","$320,800"],["Garrett
Winters","Accountant","Tokyo","8422","2011\/07\/25","$170,750"]]}
我在Java中嘗試這樣的:
ArrayList<String> list = new ArrayList<String>();
list.add("Tiger Nixon");
list.add("System Architect");
list.add("Edinburgh");
list.add("2011\/04\/25");
list.add("$320,800");
JSONArray stateArray = JSONFactoryUtil.createJSONArray();
JSONObject stateObject;
stateObject = JSONFactoryUtil.createJSONObject();
stateObject.put("data", list); // i got an error in here
stateArray.put(stateObject);
System.out.println(stateArray);
但是,我不知道如何實現這樣的對象。 有人可以幫助我嗎?
你需要寫一個自定義序列化程序..你試過什麼?請添加 –
@JoeyCiechanowicz我試圖使用JSONArray和JSONObject,它不工作。 –
「我在這裏得到一個錯誤」什麼錯誤? –