code: static Object getAdditionalFieldValue(String value, String fieldType) {
  
          Object result = null;
          if (fieldType.equalsIgnoreCase(FIELD_TYPE_DISCOVER)) {
  
              Result discoveredType = ValueDiscovery.discover(value);
  
              if (discoveredType == Result.STRING) {
                  return value;
              }
  
              if (discoveredType == Result.LONG) {
                  try {
                      // try adding the value as a long
                      return Long.parseLong(value);
                  } catch (NumberFormatException ex) {
                      // fallback on the double value
                      return value;
                  }
              }
  
              try {
                  return Double.parseDouble(value);
              } catch (NumberFormatException ex) {
                  // fallback on the string value
                  return value;
              }
          }
  
          if (fieldType.equalsIgnoreCase(FIELD_TYPE_STRING)) {
              result = value;
          }
  
          if (fieldType.equals(FIELD_TYPE_DOUBLE) || fieldType.equalsIgnoreCase(FIELD_TYPE_DOUBLE2)) {
              try {
                  result = Double.parseDouble(value);
              } catch (NumberFormatException ex) {
                  if (fieldType.equals(FIELD_TYPE_DOUBLE)) {
                      result = Double.valueOf(0);
                  }
              }
          }
  
          if (fieldType.equals(FIELD_TYPE_LONG) || fieldType.equalsIgnoreCase(FIELD_TYPE_LONG2)) {
              try {
                  result = (long) Double.parseDouble(value);
              } catch (NumberFormatException ex) {
                  if (fieldType.equals(FIELD_TYPE_LONG)) {
                      result = Long.valueOf(0);
                  }
              }
          }
  
          return result;
      }
docs: Get the field value as requested data type.
  
  @param value the value as string
  @param fieldType see field types
  @return the field value in the appropriate data type or {@literal null}.