The `InputFilterResult` is more than a error messages container... It sounds confusing.
I'd prefer `json_encode($result->getErrorMessages())`.