Class JacksonJsonHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Object>
org.springframework.http.converter.AbstractSmartHttpMessageConverter<Object>
org.springframework.http.converter.AbstractJacksonHttpMessageConverter
org.springframework.http.converter.json.JacksonJsonHttpMessageConverter
- All Implemented Interfaces:
- HttpMessageConverter<Object>,- SmartHttpMessageConverter<Object>
Implementation of 
HttpMessageConverter
 that can read and write JSON using Jackson 3.x's
 ObjectMapper.
 This converter can be used to bind to typed beans, or untyped
 HashMap instances.
 
By default, this converter supports application/json and
 application/*+json with UTF-8 character set. This
 can be overridden by setting the supportedMediaTypes
 property.
 
The default constructor loads JacksonModules
 found by MapperBuilder.findModules(ClassLoader).
 
The following hints entries are supported:
- A JSON view with a com.fasterxml.jackson.annotation.JsonViewkey and the class name of the JSON view as value.
- A filter provider with a tools.jackson.databind.ser.FilterProviderkey and the filter provider class name as value.
- Since:
- 7.0
- Author:
- Sebastien Deleuze
- 
Field SummaryFields inherited from class org.springframework.http.converter.AbstractJacksonHttpMessageConverterdefaultObjectMapperFields inherited from class org.springframework.http.converter.AbstractHttpMessageConverterlogger
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct a new instance with aJsonMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader)andProblemDetailJacksonMixin.JacksonJsonHttpMessageConverter(ObjectMapper objectMapper) Construct a new instance with the providedObjectMapper.
- 
Method SummaryModifier and TypeMethodDescriptionReturn the supported media type(s) forProblemDetail.voidsetJsonPrefix(String jsonPrefix) Specify a custom prefix to use for this view's JSON output.voidsetPrefixJson(boolean prefixJson) Indicate whether the JSON output by this view should be prefixed with ")]}', ".protected voidwritePrefix(tools.jackson.core.JsonGenerator generator, Object object) Write a prefix before the main content.Methods inherited from class org.springframework.http.converter.AbstractJacksonHttpMessageConvertercanRead, canWrite, customizeReader, customizeWriter, getCharset, getJavaType, getJsonEncoding, getObjectMapper, getObjectMappersForType, getSupportedMediaTypes, read, readInternal, registerObjectMappersForType, setSupportedMediaTypes, supportsRepeatableWrites, writeInternal, writeSuffixMethods inherited from class org.springframework.http.converter.AbstractSmartHttpMessageConvertercanWrite, supports, write, writeInternalMethods inherited from class org.springframework.http.converter.AbstractHttpMessageConverteraddDefaultHeaders, canRead, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, writeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.http.converter.HttpMessageConvertergetSupportedMediaTypesMethods inherited from interface org.springframework.http.converter.SmartHttpMessageConvertercanRead, read, write
- 
Constructor Details- 
JacksonJsonHttpMessageConverterpublic JacksonJsonHttpMessageConverter()Construct a new instance with aJsonMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader)andProblemDetailJacksonMixin.
- 
JacksonJsonHttpMessageConverterConstruct a new instance with the providedObjectMapper.- See Also:
 
 
- 
- 
Method Details- 
setJsonPrefixSpecify a custom prefix to use for this view's JSON output. Default is none.- See Also:
 
- 
setPrefixJsonpublic void setPrefixJson(boolean prefixJson) Indicate whether the JSON output by this view should be prefixed with ")]}', ". Default isfalse.Prefixing the JSON string in this manner is used to help prevent JSON Hijacking. The prefix renders the string syntactically invalid as a script so that it cannot be hijacked. This prefix should be stripped before parsing the string as JSON. - See Also:
 
- 
getMediaTypesForProblemDetailDescription copied from class:AbstractJacksonHttpMessageConverterReturn the supported media type(s) forProblemDetail. By default, an empty list, unless overridden in subclasses.- Overrides:
- getMediaTypesForProblemDetailin class- AbstractJacksonHttpMessageConverter
 
- 
writePrefixDescription copied from class:AbstractJacksonHttpMessageConverterWrite a prefix before the main content.- Overrides:
- writePrefixin class- AbstractJacksonHttpMessageConverter
- Parameters:
- generator- the generator to use for writing content.
- object- the object to write to the output message
 
 
-