Alexey Krylov opened SPR-12270 and commented
Currently only one @JsonView class is used:
JsonViewResponseBodyAdvice.java:
@Override
protected void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType,
MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response) {
JsonView annotation = returnType.getMethodAnnotation(JsonView.class);
Assert.isTrue(annotation.value().length != 0, "No view class in JsonView annotation on " + returnType);
bodyContainer.setSerializationView(annotation.value()[0]);
}
My code:
@JsonView({Category.Default.class, Product.Default.class})
@RequestMapping("/catalog.json")
public Collection<Category> getCatalog(@Named("deviceId") @RequestParam(value = "device_id", required = false) Integer deviceId) {
return retrieveCatalog(deviceId);
}
In this example only Category.Default.class will be used.
It will be very nice to have full support for @JsonView.
Affects: 4.1 GA
Referenced from: commits a3fd00e, ae43b17
Alexey Krylov opened SPR-12270 and commented
Currently only one
@JsonViewclass is used:JsonViewResponseBodyAdvice.java:
My code:
In this example only Category.Default.class will be used.
It will be very nice to have full support for
@JsonView.Affects: 4.1 GA
Referenced from: commits a3fd00e, ae43b17