code: @Override
    public Writable serialize(Object obj, ObjectInspector objInspector)
      throws SerDeException {
      StringBuilder sb = new StringBuilder();
      try {
  
        StructObjectInspector soi = (StructObjectInspector) objInspector;
        List<? extends StructField> structFields = soi.getAllStructFieldRefs();
        assert (columnNames.size() == structFields.size());
        if (obj == null) {
          sb.append("null");
        } else {
          sb.append(SerDeUtils.LBRACE);
          for (int i = 0; i < structFields.size(); i++) {
            if (i > 0) {
              sb.append(SerDeUtils.COMMA);
            }
            appendWithQuotes(sb, columnNames.get(i));
            sb.append(SerDeUtils.COLON);
            buildJSONString(sb, soi.getStructFieldData(obj, structFields.get(i)),
              structFields.get(i).getFieldObjectInspector());
          }
          sb.append(SerDeUtils.RBRACE);
        }
  
      } catch (IOException e) {
        LOG.warn("Error generating json text from object.", e);
        throw new SerDeException(e);
      }
      return new Text(sb.toString());
    }
docs: Given an object and object inspector pair, traverse the object
  and generate a Text representation of the object.