code: public synchronized String makeJsonString() {
      
      Map<String, Map<String, Long>> data =
          new HashMap<String, Map<String, Long>>();
      
      for (Group group : this) {
        Map<String, Long> groupData = new HashMap<String, Long>();
        data.put(group.getDisplayName(), groupData);
        for (Counter counter : group) {
          groupData.put(counter.getDisplayName(), counter.getCounter());
        }
      }
      return JSON.toString(data);
    }
docs: Convert a counters object into a JSON string