code: public JSONObject toJson() {
          JSONObject ret = new JSONObject();
          JSONArray columns = new JSONArray(Arrays.asList(new String[]{"time"}));
          for (String f : this.columns) {
              columns.put(f);
          }
          ret.put(KEY_COLUMNS, columns);
  
          JSONArray data = new JSONArray();
          ret.put(KEY_ROWS, data);
          for (Long ts : rows.keySet()) {
              JSONArray row = new JSONArray();
              row.put(ts);
              Map<String, Object> temp = rows.get(ts);
              for (String f : this.columns) {
                  Object val = temp.get(f);
                  row.put(val != null ? val : JSONObject.NULL);
              }
              data.put(row);
          }
  
          return ret;
      }
docs: Convert this batch into a JSON representation.
  
  @return JSONObject representing this batch.