【发布时间】:2013-03-01 13:22:14
【问题描述】:
我创建了一个类 Game,如下所示:
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 或更多。
我的问题是,如何创建游戏对象的 JSON 数组?
【问题讨论】:
-
查看 JSONArray 和 JSONObject 类
-
GSON 呢? javacodegeeks.com/2011/01/…
标签: java android json arraylist