public class JsonbHttpMessageConverter extends AbstractJsonHttpMessageConverter
HttpMessageConverter
that 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 supports application/json and application/*+json with
UTF-8 character set.
Jsonb,
JsonbBuilder,
setJsonb(javax.json.bind.Jsonb)DEFAULT_CHARSETlogger| Constructor and Description |
|---|
JsonbHttpMessageConverter()
Construct a new
JsonbHttpMessageConverter with default configuration. |
JsonbHttpMessageConverter(javax.json.bind.Jsonb jsonb)
Construct a new
JsonbHttpMessageConverter with the given delegate. |
JsonbHttpMessageConverter(javax.json.bind.JsonbConfig config)
Construct a new
JsonbHttpMessageConverter with the given configuration. |
| Modifier and Type | Method and Description |
|---|---|
javax.json.bind.Jsonb |
getJsonb()
Return the configured
Jsonb instance for this converter. |
protected java.lang.Object |
readInternal(java.lang.reflect.Type resolvedType,
java.io.Reader reader)
Template method that reads the JSON-bound object from the given
Reader. |
void |
setJsonb(javax.json.bind.Jsonb jsonb)
Set the
Jsonb instance to use. |
protected void |
writeInternal(java.lang.Object o,
java.lang.reflect.Type type,
java.io.Writer writer)
Template method that writes the JSON-bound object to the given
Writer. |
read, readInternal, setJsonPrefix, setPrefixJson, writeInternalcanRead, canWrite, supports, write, writeInternaladdDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanRead, canWrite, getSupportedMediaTypes, read, writepublic JsonbHttpMessageConverter()
JsonbHttpMessageConverter with default configuration.public JsonbHttpMessageConverter(javax.json.bind.JsonbConfig config)
JsonbHttpMessageConverter with the given configuration.config - the JsonbConfig for the underlying delegatepublic JsonbHttpMessageConverter(javax.json.bind.Jsonb jsonb)
JsonbHttpMessageConverter with the given delegate.jsonb - the Jsonb instance to usepublic void setJsonb(javax.json.bind.Jsonb jsonb)
Jsonb instance to use.
If not set, a default Jsonb instance will be created.
Setting a custom-configured Jsonb is one way to take further
control of the JSON serialization process.
JsonbHttpMessageConverter(Jsonb),
JsonbHttpMessageConverter(JsonbConfig),
JsonbBuilderpublic javax.json.bind.Jsonb getJsonb()
Jsonb instance for this converter.protected java.lang.Object readInternal(java.lang.reflect.Type resolvedType,
java.io.Reader reader)
throws java.lang.Exception
AbstractJsonHttpMessageConverterReader.readInternal in class AbstractJsonHttpMessageConverterresolvedType - the resolved generic typereader - the Reader to usejava.lang.Exception - in case of read/parse failuresprotected void writeInternal(java.lang.Object o,
@Nullable
java.lang.reflect.Type type,
java.io.Writer writer)
throws java.lang.Exception
AbstractJsonHttpMessageConverterWriter.writeInternal in class AbstractJsonHttpMessageConvertero - the object to write to the output messagetype - the type of object to write (may be null)writer - the Writer to usejava.lang.Exception - in case of write failures