If there is a DataBinder associated with the request, it is getting added to the outbound model and rendered into the Json. If my command object is named "command" the BindingResult gets added with the key "org.springframework.validation.BindingResult.command" and a value of :{"messageCodesResolver":{"prefix":""},"nestedPath":""}
This is with the SojoJsonStringWriter. Setting that key as an exclude via the following code also has no effect whatsoever:
JsonWriterConfiguratorTemplateRegistry registry = JsonWriterConfiguratorTemplateRegistry.load(request);
registry.registerConfiguratorTemplate(
new SojoJsonWriterConfiguratorTemplate(){
@Override
public SojoConfig getJsonConfig() {
SojoConfig config= new SojoConfig();
String[] excludes = new String[] {
"org.springframework.validation.BindingResult.command"
};
config.setExcludedProperties(excludes);
return config;
}
}
);
If I use JsonlibJsonStringWriter instead of the sojo writer,it throws an exception because of a cycle in the object graph. This problem has existed in the jsonlib writer for at least 8 or 9 months and the last time I investigated it, the cycle was a result of the HttpServletRequest being part of the BindingResult. I don't remember which property of the request generated the cycle but it shuld be easy enough to track down. I actually abandoned the use of jsonlib writer because of this issue, though I was able to correct it by modifying the writer config and ignoring all objects of class BindingResult.
It seems to me that putting the BindingResult directly into the output is a bug.
I should mention that this is spring 2.5.6 and spring-json-1.2, which was downloaded only a couple of days ago. The problem existed in spring-json-1.1, too, at least with the jsonlib writer.