#11309 [Form] Implement JsonSerializable for errors.

| Q             | A
| ------------- | ---
| Tests pass?   | yes
| Fixed tickets | #11309
| License       | MIT
As cause is `mixed` I don't think this will always work.