Class MapJsonSerializer
java.lang.Object
org.springframework.integration.ip.tcp.serializer.MapJsonSerializer
- All Implemented Interfaces:
Deserializer<Map<?,
,?>> Serializer<Map<?,
?>>
public class MapJsonSerializer
extends Object
implements Serializer<Map<?,?>>, Deserializer<Map<?,?>>
Serializes a
Map
as JSON. Deserializes JSON to
a Map
. The default JsonObjectMapperProvider.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.
- Since:
- 3.0
- Author:
- Gary Russell, Artem Bilan
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionMap<?,
?> deserialize
(InputStream inputStream) void
serialize
(Map<?, ?> object, OutputStream outputStream) void
setJsonObjectMapper
(JsonObjectMapper<?, ?> jsonObjectMapper) AnJsonObjectMapper
to be used for the conversion to/from JSON.void
setPacketDeserializer
(Deserializer<byte[]> packetDeserializer) ADeserializer
that will construct the full JSON content from the stream which is then passed to the JsonObjectMapper.void
setPacketSerializer
(Serializer<byte[]> packetSerializer) ASerializer
that will delimit the full JSON content in the stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.serializer.Deserializer
deserializeFromByteArray
Methods inherited from interface org.springframework.core.serializer.Serializer
serializeToByteArray
-
Constructor Details
-
MapJsonSerializer
public MapJsonSerializer()
-
-
Method Details
-
setJsonObjectMapper
AnJsonObjectMapper
to be used for the conversion to/from JSON. Use this if you wish to set additionalJsonObjectMapper
implementation features.- Parameters:
jsonObjectMapper
- the jsonObjectMapper.
-
setPacketDeserializer
ADeserializer
that will construct the full JSON content from the stream which is then passed to the JsonObjectMapper. Default isByteArrayLfSerializer
.- Parameters:
packetDeserializer
- the packetDeserializer
-
setPacketSerializer
ASerializer
that will delimit the full JSON content in the stream. Default isByteArrayLfSerializer
.- Parameters:
packetSerializer
- the packetSerializer
-
deserialize
- Specified by:
deserialize
in interfaceDeserializer<Map<?,
?>> - Throws:
IOException
-
serialize
- Specified by:
serialize
in interfaceSerializer<Map<?,
?>> - Throws:
IOException
-