code: private static JsonObject getFieldJsonObject(Field field) {
          JsonObject fieldObj = new JsonObject();
          fieldObj.add("type", field.getType());
          fieldObj.add("key", field.getKey());
          fieldObj.add("displayName", field.getDisplayName());
  
          String fieldDesc = field.getDescription();
          if (fieldDesc != null) {
              fieldObj.add("description", field.getDescription());
          }
  
          Boolean fieldIsHidden = field.getIsHidden();
          if (fieldIsHidden != null) {
              fieldObj.add("hidden", field.getIsHidden());
          }
  
          JsonArray array = new JsonArray();
          List<String> options = field.getOptions();
          if (options != null && !options.isEmpty()) {
              for (String option : options) {
                  JsonObject optionObj = new JsonObject();
                  optionObj.add("key", option);
  
                  array.add(optionObj);
              }
              fieldObj.add("options", array);
          }
  
          return fieldObj;
      }
docs: Gets the JsonObject representation of the given field object.
  @param field represents a template field
  @return the json object