code: public static Object evaluate(Object jsonPathResult, String jsonPathFunction) {
          switch (jsonPathFunction) {
              case "exists":
                  return jsonPathResult != null;
              case "size":
                  if (jsonPathResult instanceof JSONArray) {
                      return ((JSONArray) jsonPathResult).size();
                  } else if (jsonPathResult instanceof JSONObject) {
                      return ((JSONObject) jsonPathResult).size();
                  } else {
                      return jsonPathResult != null ? 1 : 0;
                  }
              case "keySet":
                  if (jsonPathResult instanceof JSONObject) {
                      return ((JSONObject) jsonPathResult).keySet();
                  } else {
                      return Collections.emptySet();
                  }
              case "values":
                  if (jsonPathResult instanceof JSONObject) {
                      Object[] valueObjects = ((JSONObject) jsonPathResult).values().toArray();
                      List<String> values = new ArrayList<>(valueObjects.length);
                      for (Object value : valueObjects) {
                          if (value instanceof JSONObject) {
                              values.add(((JSONObject) value).toJSONString());
                          } else if (value instanceof JSONArray) {
                              values.add(((JSONArray) value).toJSONString());
                          } else {
                              values.add(String.valueOf(value));
                          }
                      }
  
                      return values.toString();
                  } else {
                      return new Object[]{};
                  }
              case "toString":
                  if (jsonPathResult instanceof JSONArray) {
                      return ((JSONArray) jsonPathResult).toJSONString();
                  } else if (jsonPathResult instanceof JSONObject) {
                      return ((JSONObject) jsonPathResult).toJSONString();
                  } else {
                      return jsonPathResult.toString();
                  }
          }
  
          return jsonPathResult;
      }
docs: Evaluates function on result. Supported functions are size(), keySet(), values() and toString().
  @param jsonPathResult
  @param jsonPathFunction
  @return