Class MapJsonSerializer
java.lang.Object
org.springframework.integration.ip.tcp.serializer.MapJsonSerializer
- All Implemented Interfaces:
org.springframework.core.serializer.Deserializer<java.util.Map<?,?>>,org.springframework.core.serializer.Serializer<java.util.Map<?,?>>
public class MapJsonSerializer
extends java.lang.Object
implements org.springframework.core.serializer.Serializer<java.util.Map<?,?>>, org.springframework.core.serializer.Deserializer<java.util.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
-
Constructor Summary
Constructors Constructor Description MapJsonSerializer() -
Method Summary
Modifier and Type Method Description java.util.Map<?,?>deserialize(java.io.InputStream inputStream)voidserialize(java.util.Map<?,?> object, java.io.OutputStream outputStream)voidsetJsonObjectMapper(org.springframework.integration.support.json.JsonObjectMapper<?,?> jsonObjectMapper)AnJsonObjectMapperto be used for the conversion to/from JSON.voidsetPacketDeserializer(org.springframework.core.serializer.Deserializer<byte[]> packetDeserializer)ADeserializerthat will construct the full JSON content from the stream which is then passed to the JsonObjectMapper.voidsetPacketSerializer(org.springframework.core.serializer.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, wait
-
Constructor Details
-
MapJsonSerializer
public MapJsonSerializer()
-
-
Method Details
-
setJsonObjectMapper
public void setJsonObjectMapper(org.springframework.integration.support.json.JsonObjectMapper<?,?> jsonObjectMapper)AnJsonObjectMapperto be used for the conversion to/from JSON. Use this if you wish to set additionalJsonObjectMapperimplementation features.- Parameters:
jsonObjectMapper- the jsonObjectMapper.
-
setPacketDeserializer
public void setPacketDeserializer(org.springframework.core.serializer.Deserializer<byte[]> packetDeserializer)ADeserializerthat will construct the full JSON content from the stream which is then passed to the JsonObjectMapper. Default isByteArrayLfSerializer.- Parameters:
packetDeserializer- the packetDeserializer
-
setPacketSerializer
public void setPacketSerializer(org.springframework.core.serializer.Serializer<byte[]> packetSerializer)ASerializerthat will delimit the full JSON content in the stream. Default isByteArrayLfSerializer.- Parameters:
packetSerializer- the packetSerializer
-
deserialize
public java.util.Map<?,?> deserialize(java.io.InputStream inputStream) throws java.io.IOException- Specified by:
deserializein interfaceorg.springframework.core.serializer.Deserializer<java.util.Map<?,?>>- Throws:
java.io.IOException
-
serialize
public void serialize(java.util.Map<?,?> object, java.io.OutputStream outputStream) throws java.io.IOException- Specified by:
serializein interfaceorg.springframework.core.serializer.Serializer<java.util.Map<?,?>>- Throws:
java.io.IOException
-