code: protected static Object toSafeJsonValue(Object value) {
          if (value == null) {
              return null;
          } else {
              if (value instanceof Boolean || value instanceof String || value instanceof Number) {
                  return value;
              }
              if (value instanceof Iterable) {
                  Iterable iterable = (Iterable) value;
                  List answer = new ArrayList<>();
                  for (Object item : iterable) {
                      Object itemJson = toSafeJsonValue(item);
                      if (itemJson != null) {
                          answer.add(itemJson);
                      }
                  }
                  return answer;
              }
              if (value instanceof ProjectProvider) {
                  ProjectProvider projectProvider = (ProjectProvider) value;
                  return projectProvider.getType();
              }
              if (value instanceof ProjectType) {
                  ProjectType projectType = (ProjectType) value;
                  return projectType.getType();
              }
              if (value instanceof StackFacet) {
                  StackFacet stackFacet = (StackFacet) value;
                  Stack stack = stackFacet.getStack();
                  if (stack != null) {
                      return stack.getName();
                  } else {
                      return null;
                  }
              }
              value = Proxies.unwrap(value);
              if (value instanceof ProjectProvider) {
                  ProjectProvider projectProvider = (ProjectProvider) value;
                  return projectProvider.getType();
              }
              if (value instanceof ProjectType) {
                  ProjectType projectType = (ProjectType) value;
                  return projectType.getType();
              }
              if (value instanceof StackFacet) {
                  StackFacet stackFacet = (StackFacet) value;
                  Stack stack = stackFacet.getStack();
                  if (stack != null) {
                      return stack.getName();
                  } else {
                      return null;
                  }
              }
              if (isJsonObject(value)) {
                  return value;
              }
              return value.toString();
          }
      }
docs: Lets return a safe JSON value