Class JsonbHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
org.springframework.http.converter.AbstractGenericHttpMessageConverter<Object>
org.springframework.http.converter.json.AbstractJsonHttpMessageConverter
org.springframework.http.converter.json.JsonbHttpMessageConverter
- All Implemented Interfaces:
GenericHttpMessageConverter<Object>
,HttpMessageConverter<Object>
Implementation of
HttpMessageConverter
that can read and write JSON using the
JSON Binding API.
This converter can be used to bind to typed beans or untyped HashMap
s.
By default, it supports application/json
and application/*+json
with
UTF-8
character set.
- Since:
- 5.0
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class org.springframework.http.converter.json.AbstractJsonHttpMessageConverter
DEFAULT_CHARSET
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger
-
Constructor Summary
ConstructorDescriptionConstruct a newJsonbHttpMessageConverter
with default configuration.JsonbHttpMessageConverter
(Jsonb jsonb) Construct a newJsonbHttpMessageConverter
with the given delegate.JsonbHttpMessageConverter
(JsonbConfig config) Construct a newJsonbHttpMessageConverter
with the given configuration. -
Method Summary
Modifier and TypeMethodDescriptiongetJsonb()
Return the configuredJsonb
instance for this converter.protected Object
readInternal
(Type resolvedType, Reader reader) Template method that reads the JSON-bound object from the givenReader
.void
Set theJsonb
instance to use.protected boolean
Indicates whether this message converter can write the given object multiple times.protected void
writeInternal
(Object object, Type type, Writer writer) Template method that writes the JSON-bound object to the givenWriter
.Methods inherited from class org.springframework.http.converter.json.AbstractJsonHttpMessageConverter
read, readInternal, setJsonPrefix, setPrefixJson, writeInternal
Methods inherited from class org.springframework.http.converter.AbstractGenericHttpMessageConverter
canRead, canWrite, supports, write, writeInternal
Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.http.converter.HttpMessageConverter
canRead, canWrite, getSupportedMediaTypes, getSupportedMediaTypes, read, write
-
Constructor Details
-
JsonbHttpMessageConverter
public JsonbHttpMessageConverter()Construct a newJsonbHttpMessageConverter
with default configuration. -
JsonbHttpMessageConverter
Construct a newJsonbHttpMessageConverter
with the given configuration.- Parameters:
config
- theJsonbConfig
for the underlying delegate
-
JsonbHttpMessageConverter
Construct a newJsonbHttpMessageConverter
with the given delegate.- Parameters:
jsonb
- the Jsonb instance to use
-
-
Method Details
-
setJsonb
Set theJsonb
instance to use. If not set, a defaultJsonb
instance will be created.Setting a custom-configured
Jsonb
is one way to take further control of the JSON serialization process. -
getJsonb
Return the configuredJsonb
instance for this converter. -
readInternal
Description copied from class:AbstractJsonHttpMessageConverter
Template method that reads the JSON-bound object from the givenReader
.- Specified by:
readInternal
in classAbstractJsonHttpMessageConverter
- Parameters:
resolvedType
- the resolved generic typereader
- the Reader to use- Returns:
- the JSON-bound object
- Throws:
Exception
- in case of read/parse failures
-
writeInternal
Description copied from class:AbstractJsonHttpMessageConverter
Template method that writes the JSON-bound object to the givenWriter
.- Specified by:
writeInternal
in classAbstractJsonHttpMessageConverter
- Parameters:
object
- the object to write to the output messagetype
- the type of object to write (may benull
)writer
- the Writer to use- Throws:
Exception
- in case of write failures
-
supportsRepeatableWrites
Description copied from class:AbstractHttpMessageConverter
Indicates whether this message converter can write the given object multiple times.Default implementation returns
false
.- Overrides:
supportsRepeatableWrites
in classAbstractHttpMessageConverter<Object>
- Parameters:
o
- the object t- Returns:
true
ift
can be written repeatedly;false
otherwise
-