private JSONArray getPlansJson(Collection<Plan> uidPlans, User starter) throws JSONException {
        JSONArray plansJson = new JSONArray();
        for (Plan plan : uidPlans) {
            JSONObject planJson = new JSONObject();
            planJson.put("pid", plan.getPid());
            planJson.put("planname", plan.getPlanname());
            planJson.put("starter", getStarterJson(plan));
            planJson.put("start_place", plan.getStartPlace());
            planJson.put("end_place", plan.getEndPlace());
            planJson.put("end_location", plan.getEndLocation());
            planJson.put("start_time", plan.getStartTime());
            planJson.put("joiners", getJoinersJson(plan));
            if (starter == null) {
                planJson.put("role", "none");
            } else {
                planJson.put("role", (plan.getStarter().equals(starter)) ? "starter" : "joiner");
            }
            plansJson.put(planJson);
        }
        return plansJson;
    }