code: protected void buildJsonCategoryList() {
  
          CmsCategoryService catService = CmsCategoryService.getInstance();
          List<CmsCategory> foundCategories = Collections.emptyList();
          String editedResource = null;
          if (CmsStringUtil.isNotEmpty(getParamResource())) {
              editedResource = getParamResource();
          }
          try {
              foundCategories = catService.readCategories(getCms(), "", true, editedResource);
          } catch (CmsException e) {
              // error reading categories
          }
  
          // the next lines sort the categories according to their path
          Map<String, CmsCategory> sorted = new TreeMap<String, CmsCategory>();
  
          Iterator<CmsCategory> i = foundCategories.iterator();
          while (i.hasNext()) {
              CmsCategory category = i.next();
              String categoryPath = category.getPath();
              if (sorted.get(categoryPath) != null) {
                  continue;
              }
              sorted.put(categoryPath, category);
          }
  
          foundCategories = new ArrayList<CmsCategory>(sorted.values());
          JSONArray categories = new JSONArray();
          i = foundCategories.iterator();
          while (i.hasNext()) {
              CmsCategory cat = i.next();
  
              JSONObject jsonObj = new JSONObject();
              try {
                  // 1: category title
                  jsonObj.put("title", cat.getTitle());
                  // 2: category path
                  jsonObj.put("path", cat.getPath());
                  // 3: category root path
                  jsonObj.put("rootpath", cat.getRootPath());
                  // 4 category level
                  jsonObj.put("level", CmsResource.getPathLevel(cat.getPath()));
                  // 4: active flag
                  jsonObj.put("active", false);
                  categories.put(jsonObj);
              } catch (JSONException e) {
                  // TODO: error handling
              }
          }
          JspWriter out = getJsp().getJspContext().getOut();
          try {
              out.print(categories.toString());
          } catch (IOException e) {
              if (LOG.isErrorEnabled()) {
                  LOG.error(e.getLocalizedMessage(), e);
              }
          }
  
      }
docs: Builds the JSON code for the category list as JSON array.<p>