public class MapJsonSerializer
extends java.lang.Object
implements org.springframework.core.serializer.Serializer<java.util.Map<?,?>>, org.springframework.core.serializer.Deserializer<java.util.Map<?,?>>
Map
as JSON. Deserializes JSON to
a Map
. The default JacksonJsonObjectMapperProvider.newInstance()
can be
overridden using setJsonObjectMapper(JsonObjectMapper)
.
The JSON deserializer can't delimit multiple JSON
objects. Therefore another (de)serializer is used to
apply structure to the stream. By default, this is a
simple ByteArrayLfSerializer
, which inserts/expects
LF (0x0a) between messages.Constructor and Description |
---|
MapJsonSerializer() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<?,?> |
deserialize(java.io.InputStream inputStream) |
void |
serialize(java.util.Map<?,?> object,
java.io.OutputStream outputStream) |
void |
setJsonObjectMapper(JsonObjectMapper<?> jsonObjectMapper)
An
JsonObjectMapper to be used for the conversion to/from
JSON. |
void |
setPacketDeserializer(org.springframework.core.serializer.Deserializer<byte[]> packetDeserializer)
A
Deserializer that will construct the full JSON content from
the stream which is then passed to the JsonObjectMapper. |
void |
setPacketSerializer(org.springframework.core.serializer.Serializer<byte[]> packetSerializer)
A
Serializer that will delimit the full JSON content in
the stream. |
public void setJsonObjectMapper(JsonObjectMapper<?> jsonObjectMapper)
JsonObjectMapper
to be used for the conversion to/from
JSON. Use this if you wish to set additional JsonObjectMapper
implementation features.jsonObjectMapper
- the jsonObjectMapper.public void setPacketDeserializer(org.springframework.core.serializer.Deserializer<byte[]> packetDeserializer)
Deserializer
that will construct the full JSON content from
the stream which is then passed to the JsonObjectMapper. Default is
ByteArrayLfSerializer
.packetDeserializer
- the packetDeserializerpublic void setPacketSerializer(org.springframework.core.serializer.Serializer<byte[]> packetSerializer)
Serializer
that will delimit the full JSON content in
the stream. Default is
ByteArrayLfSerializer
.packetSerializer
- the packetSerializerpublic java.util.Map<?,?> deserialize(java.io.InputStream inputStream) throws java.io.IOException
deserialize
in interface org.springframework.core.serializer.Deserializer<java.util.Map<?,?>>
java.io.IOException
public void serialize(java.util.Map<?,?> object, java.io.OutputStream outputStream) throws java.io.IOException
serialize
in interface org.springframework.core.serializer.Serializer<java.util.Map<?,?>>
java.io.IOException