Is there any way that I can use Jackson JSON Views or something like it, without having to annotate the original bean class? I’m looking for some kind of runtime/dynamic configuration to let me do something similar.
My bean is an @Entity packaged in a JAR that may be shared by multiple projects. I’m trying to avoid touching and re-packaging the shared JAR because of UI changes in the consuming projects.
Ideally I’d like to do something like
jsonViewBuilder = createViewBuilder(View.class);
jsonViewBuilder.addProperty("property1");
jsonViewBuilder.addProperty("property2");
to replace
Bean {
@JsonView(View.class)
String property1;
@JsonView(View.class)
String property2;
}
Any ideas?
Underlying environment: Spring 3.0, Spring MVC and Glassfish 3.1.1.
How about using the Mix-In feature?
http://wiki.fasterxml.com/JacksonMixInAnnotations
http://www.cowtowncoder.com/blog/archives/2009/08/entry_305.html