private void writeObject(JsonGenerator jg, Object value) throws IOException {
    if(value == null) {
      jg.writeNull();
    } else {
      Class<?> c = value.getClass();
      if (c.isArray()) {
        jg.writeStartArray();
        int len = Array.getLength(value);
        for (int j = 0; j < len; j++) {
          Object item = Array.get(value, j);
          writeObject(jg, item);
        }
        jg.writeEndArray();
      } else if (value instanceof Number n) {
        jg.writeNumber(n.toString());
      } else if (value instanceof Boolean b) {
        jg.writeBoolean(b);
      } else if (value instanceof CompositeData cds) {
        CompositeType comp = cds.getCompositeType();
        Set<String> keys = comp.keySet();
        jg.writeStartObject();
        for(String key: keys) {
          writeAttribute(jg, key, cds.get(key));
        }
        jg.writeEndObject();
      } else if (value instanceof TabularData tds) {
        jg.writeStartArray();
        for(Object entry : tds.values()) {
          writeObject(jg, entry);
        }
        jg.writeEndArray();
      } else {
        jg.writeString(value.toString());
      }
    }
  }
Process a GET request for the specified resource.

@param request
         The servlet request we are processing
@param response
         The servlet response we are creating
common/src/java/org/apache/hive/http/JMXJsonServlet.java