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>
public class JsonbHttpMessageConverter extends AbstractJsonHttpMessageConverter
Implementation ofHttpMessageConverterthat can read and write JSON using the JSON Binding API.This converter can be used to bind to typed beans or untyped
HashMaps. By default, it supportsapplication/jsonandapplication/*+jsonwithUTF-8character set.- Since:
- 5.0
- Author:
- Juergen Hoeller
- See Also:
Jsonb,JsonbBuilder,setJsonb(javax.json.bind.Jsonb)
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
Constructors Constructor Description JsonbHttpMessageConverter()Construct a newJsonbHttpMessageConverterwith default configuration.JsonbHttpMessageConverter(javax.json.bind.Jsonb jsonb)Construct a newJsonbHttpMessageConverterwith the given delegate.JsonbHttpMessageConverter(javax.json.bind.JsonbConfig config)Construct a newJsonbHttpMessageConverterwith the given configuration.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.json.bind.JsonbgetJsonb()Return the configuredJsonbinstance for this converter.protected ObjectreadInternal(Type resolvedType, Reader reader)Template method that reads the JSON-bound object from the givenReader.voidsetJsonb(javax.json.bind.Jsonb jsonb)Set theJsonbinstance to use.protected voidwriteInternal(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, read, write
Constructor Detail
JsonbHttpMessageConverter
public JsonbHttpMessageConverter()
Construct a newJsonbHttpMessageConverterwith default configuration.
JsonbHttpMessageConverter
public JsonbHttpMessageConverter(javax.json.bind.JsonbConfig config)
Construct a newJsonbHttpMessageConverterwith the given configuration.- Parameters:
config- theJsonbConfigfor the underlying delegate
JsonbHttpMessageConverter
public JsonbHttpMessageConverter(javax.json.bind.Jsonb jsonb)
Construct a newJsonbHttpMessageConverterwith the given delegate.- Parameters:
jsonb- the Jsonb instance to use
Method Detail
setJsonb
public void setJsonb(javax.json.bind.Jsonb jsonb)
Set theJsonbinstance to use. If not set, a defaultJsonbinstance will be created.Setting a custom-configured
Jsonbis one way to take further control of the JSON serialization process.- See Also:
JsonbHttpMessageConverter(Jsonb),JsonbHttpMessageConverter(JsonbConfig),JsonbBuilder
getJsonb
public javax.json.bind.Jsonb getJsonb()
Return the configuredJsonbinstance for this converter.
readInternal
protected Object readInternal(Type resolvedType, Reader reader) throws Exception
Description copied from class:AbstractJsonHttpMessageConverterTemplate method that reads the JSON-bound object from the givenReader.- Specified by:
readInternalin 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
protected void writeInternal(Object object, @Nullable Type type, Writer writer) throws Exception
Description copied from class:AbstractJsonHttpMessageConverterTemplate method that writes the JSON-bound object to the givenWriter.- Specified by:
writeInternalin 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