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
Constructors Constructor Description MapJsonSerializer() -
Method Summary
Modifier and Type Method Description Map<?,?>deserialize(InputStream inputStream)voidserialize(Map<?,?> object, OutputStream outputStream)voidsetJsonObjectMapper(JsonObjectMapper<?,?> jsonObjectMapper)AnJsonObjectMapperto be used for the conversion to/from JSON.voidsetPacketDeserializer(Deserializer<byte[]> packetDeserializer)ADeserializerthat will construct the full JSON content from the stream which is then passed to the JsonObjectMapper.voidsetPacketSerializer(Serializer<byte[]> packetSerializer)ASerializerthat 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, waitMethods inherited from interface org.springframework.core.serializer.Deserializer
deserializeFromByteArrayMethods inherited from interface org.springframework.core.serializer.Serializer
serializeToByteArray
-
Constructor Details
-
MapJsonSerializer
public MapJsonSerializer()
-
-
Method Details
-
setJsonObjectMapper
AnJsonObjectMapperto be used for the conversion to/from JSON. Use this if you wish to set additionalJsonObjectMapperimplementation features.- Parameters:
jsonObjectMapper- the jsonObjectMapper.
-
setPacketDeserializer
ADeserializerthat will construct the full JSON content from the stream which is then passed to the JsonObjectMapper. Default isByteArrayLfSerializer.- Parameters:
packetDeserializer- the packetDeserializer
-
setPacketSerializer
ASerializerthat will delimit the full JSON content in the stream. Default isByteArrayLfSerializer.- Parameters:
packetSerializer- the packetSerializer
-
deserialize
- Specified by:
deserializein interfaceDeserializer<Map<?,?>>- Throws:
IOException
-
serialize
- Specified by:
serializein interfaceSerializer<Map<?,?>>- Throws:
IOException
-