#11309 [Form] Implement JsonSerializable for errors.

| Q             | A
| ------------- | ---
| Tests pass?   | yes
| Fixed tickets | #11309
| License       | MIT