创建JSON数据

I am using this answer as a basis, but I cannot get it to work. My major problem is that the .add() method isn't available in the JSONArray class.

establishmentList is just an ArrayList.

    JSONObject json      = new JSONObject();
    JSONArray  addresses = new JSONArray();
    JSONObject address;
    public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        for (Establishment est : establishmentList) {
            address = new JSONObject();
            try {
                address.put("name", est.getBusinessName());
                address.put("address", est.getAddress());
                address.put("rating", est.getRating());
                addresses.add(address); //<-- method not available, compiler error
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        json.put("Addresses", addresses);
        resp.setContentType("application/json");
        PrintWriter out = resp.getWriter();
        out.println(json.toString());
    }   

My imports for the JSON are:

      import com.google.appengine.labs.repackaged.org.json.JSONArray;
      import com.google.appengine.labs.repackaged.org.json.JSONException;
      import com.google.appengine.labs.repackaged.org.json.JSONObject;

It should be:

            addresses.put(address);