Garden\Exception\ValidationException::jsonSerialize PHP Method

jsonSerialize() public method

Specify data which should be serialized to JSON.
public jsonSerialize ( ) : mixed
return mixed data which can be serialized by json_encode, which is a value of any type other than a resource.
    public function jsonSerialize()
    {
        $errors = $this->validation->getErrorsFlat();
        if (count($errors) === 1) {
            $message = Validation::errorMessage($errors[0]);
        } else {
            $message = t('Validation failed.');
        }
        $result = ['message' => $message, 'status' => $this->getCode(), 'errors' => $errors];
        return $result;
    }
ValidationException