private JSONObject getCountersJson(Counters ctrs) throws JSONException {
      JSONObject countersJson = new JSONObject();
      Iterator<Counters.Group> iterator = ctrs.iterator();
      while(iterator.hasNext()) {
        Counters.Group group = iterator.next();
        Iterator<Counters.Counter> groupIterator = group.iterator();
        JSONObject groupJson = new JSONObject();
        while(groupIterator.hasNext()) {
          Counters.Counter counter = groupIterator.next();
          groupJson.put(counter.getDisplayName(), counter.getCounter());
        }
        countersJson.put(group.getDisplayName(), groupJson);
      }
      return countersJson;
    }
Preferred objectMapper for this class.

It must be used to have things work in shaded environment (and its also more performant).
ql/src/java/org/apache/hadoop/hive/ql/QueryDisplay.java