hierarchyJSON.put("name", hierarchy.getName());
hierarchyJSON.put("description", hierarchy.getName());
List levels = hierarchy.getLevels();
JSONArray levelsJSON = new JSONArray();
for(int i = 0; i < levels.size(); i++) {
Level level = (Level)levels.get(i);
JSONObject levelJSON = new JSONObject();
levelJSON.put("id", level.getName());
levelJSON.put("name", level.getName());
levelJSON.put("description", level.getName());
levelJSON.put("feature", level.getFeatureName());
levelsJSON.put(levelJSON);
}
hierarchyJSON.put("levels", levelsJSON);
hierarchiesJSON.put(hierarchyJSON);