ArrayList <Object> JSON

Próbuję zwrócić dane JSON z moim restletem. Mogę zwrócić JSON pojedynczego przedmiotu z ..

import org.json.JSONObject;

Site aSite = new Site().getSite();   
JSONObject aSiteJson = new JSONObject(aSite);
return aSiteJson.toString();

Zwraca: {„name”: „qwerty”, „url”: „www.qwerty.com”}

Jak zwrócić JSON dla obiektu ArrayList

ArrayList<Site> allSites = new SitesCollection().getAllSites();   
JSONObject allSitesJson = new JSONObject(allSites);
return allSitesJson.toString();

Zwraca: {"empty": false}

ArrayList<Site> allSites = new SitesCollection().getAllSites();   
JSONArray allSitesJson = new JSONArray(allSites);
return allSitesJson.toString();

Zwraca: ["com.sample.Site@4a7140", "com.sample.Site@1512c2e", "com.sample.Site@2bba21", "com.sample.Site@c8d0b7"]

Oto moja klasa strony

public class Site {
private String name;
private String url;

public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public String getUrl() {
    return url;
}
public void setUrl(String url) {
    this.url = url;
}

public Site(String name, String url) {
    super();
    this.name = name;
    this.url = url;
}       

}

Dzięki

questionAnswers(4)

yourAnswerToTheQuestion