src/Exception/ValidationException.php
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;
    }
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;
    }
Specify data which should be serialized to JSON.

@link http://php.net/manual/en/jsonserializable.jsonserialize.php
@return mixed data which can be serialized by <b>json_encode</b>,
which is a value of any type other than a resource.