spring-framework / org.springframework.web.servlet.mvc.method.annotation / JsonViewRequestBodyAdvice

JsonViewRequestBodyAdvice

open class JsonViewRequestBodyAdvice : RequestBodyAdviceAdapter

A RequestBodyAdvice implementation that adds support for Jackson's @JsonView annotation declared on a Spring MVC @HttpEntity or @RequestBody method parameter.

The deserialization view specified in the annotation will be passed in to the org.springframework.http.converter.json.MappingJackson2HttpMessageConverter which will then use it to deserialize the request body with.

Note that despite @JsonView allowing for more than one class to be specified, the use for a request body advice is only supported with exactly one class argument. Consider the use of a composite interface.

Author
Sebastien Deleuze

Since
4.2

See Also
com.fasterxml.jackson.annotation.JsonViewcom.fasterxml.jackson.databind.ObjectMapper#readerWithView(Class)

Constructors

<init>

JsonViewRequestBodyAdvice()

A RequestBodyAdvice implementation that adds support for Jackson's @JsonView annotation declared on a Spring MVC @HttpEntity or @RequestBody method parameter.

The deserialization view specified in the annotation will be passed in to the org.springframework.http.converter.json.MappingJackson2HttpMessageConverter which will then use it to deserialize the request body with.

Note that despite @JsonView allowing for more than one class to be specified, the use for a request body advice is only supported with exactly one class argument. Consider the use of a composite interface.

Functions

beforeBodyRead

open fun beforeBodyRead(inputMessage: HttpInputMessage, methodParameter: MethodParameter, targetType: Type, selectedConverterType: Class<out HttpMessageConverter<*>>): HttpInputMessage

supports

open fun supports(methodParameter: MethodParameter, targetType: Type, converterType: Class<out HttpMessageConverter<*>>): Boolean