Add methods for JSON serialization to Errors and Error