writer.key("errors");
writer.array();
for (Object o : errors.getAllErrors()) {
if (o instanceof FieldError) {
FieldError fe = (FieldError) o;
writer.object();
json.property("object", fe.getObjectName());
json.property("field", fe.getField());
json.property("rejected-value", fe.getRejectedValue());
Locale locale = LocaleContextHolder.getLocale();
if (applicationContext != null) {
json.property("message", applicationContext.getMessage(fe, locale));
}
else {
json.property("message", fe.getDefaultMessage());
}
writer.endObject();
} else if (o instanceof ObjectError) {
ObjectError fe = (ObjectError) o;
writer.object();
json.property("object", fe.getObjectName());
Locale locale = LocaleContextHolder.getLocale();
if (applicationContext != null) {
json.property("message", applicationContext.getMessage(fe, locale));
}
else {
json.property("message", fe.getDefaultMessage());
}
writer.endObject();
}
}
writer.endArray();