Class MappingJacksonValue
- java.lang.Object
- org.springframework.http.converter.json.MappingJacksonValue
public class MappingJacksonValue extends Object
A simple holder for the POJO to serialize viaMappingJackson2HttpMessageConverter
along with further serialization instructions to be passed in to the converter.On the server side this wrapper is added with a
ResponseBodyInterceptor
after content negotiation selects the converter to use but before the write.On the client side, simply wrap the POJO and pass it in to the
RestTemplate
.- Since:
- 4.1
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description MappingJacksonValue(Object value)
Create a new instance wrapping the given POJO to be serialized.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FilterProvider
getFilters()
Return the Jackson filter provider to use.String
getJsonpFunction()
Deprecated.Will be removed as of Spring Framework 5.1, use CORS instead.Class<?>
getSerializationView()
Return the serialization view to use.Object
getValue()
Return the POJO that needs to be serialized.void
setFilters(FilterProvider filters)
Set the Jackson filter provider to serialize the POJO with.void
setJsonpFunction(String functionName)
Deprecated.Will be removed as of Spring Framework 5.1, use CORS instead.void
setSerializationView(Class<?> serializationView)
Set the serialization view to serialize the POJO with.void
setValue(Object value)
Modify the POJO to serialize.
Constructor Detail
MappingJacksonValue
public MappingJacksonValue(Object value)
Create a new instance wrapping the given POJO to be serialized.- Parameters:
value
- the Object to be serialized
Method Detail
setSerializationView
public void setSerializationView(Class<?> serializationView)
Set the serialization view to serialize the POJO with.- See Also:
ObjectMapper.writerWithView(Class)
,JsonView
getSerializationView
public Class<?> getSerializationView()
Return the serialization view to use.- See Also:
ObjectMapper.writerWithView(Class)
,JsonView
setFilters
public void setFilters(FilterProvider filters)
Set the Jackson filter provider to serialize the POJO with.- Since:
- 4.2
- See Also:
ObjectMapper.writer(FilterProvider)
,JsonFilter
,Jackson2ObjectMapperBuilder.filters(FilterProvider)
getFilters
public FilterProvider getFilters()
Return the Jackson filter provider to use.- Since:
- 4.2
- See Also:
ObjectMapper.writer(FilterProvider)
,JsonFilter
setJsonpFunction
@Deprecated public void setJsonpFunction(String functionName)
Deprecated.Will be removed as of Spring Framework 5.1, use CORS instead.Set the name of the JSONP function name.
getJsonpFunction
@Deprecated public String getJsonpFunction()
Deprecated.Will be removed as of Spring Framework 5.1, use CORS instead.Return the configured JSONP function name.