我創建了一個類遊戲,看起來像這樣的Java對象的JSON數組:創建的Android
public class Game{
private String name;
private String location;
private int participants;
public Game(String name, String location, int participants){
this.name = name;
this.location = location;
this. participants = participatns;
}
//getters and setters of all properties
而且我有一個ArrayList的,看起來像這樣:
ArrayList<Game>gameList = new ArrayList<Game>();
此ArrayList包含5場比賽。我想把這些遊戲發送到一個php腳本中,所以我認爲最聰明的方法是創建一個JSON數組對象並將它們發送給php腳本,因爲這些遊戲在某些時候也可能會達到100個或更多。
我的問題是,我如何創建一個Game對象的JSON數組?
看看JSONArray和JSONObject類 – x4rf41 2013-03-01 13:23:22
GSON呢? http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html – fmsf 2013-03-01 13:31:46