Dynamic Selection Of JsonView in Spring MVC Controller

On the off chance someone else wants to achieve the same thing, it actually is very simple. You can directly return aorg.springframework.http.converter.json.MappingJacksonValue instance from your controller that contains both the object that you want to serialise and the view class. This will be picked up by the org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter#writeInternal method and the appropriate view will be … Read more