public class MapJsonSerializer extends Object implements Serializer<Map<?,?>>, Deserializer<Map<?,?>>
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.
Constructor and Description |
---|
MapJsonSerializer() |
Modifier and Type | Method and Description |
---|---|
Map<?,?> |
deserialize(InputStream inputStream) |
void |
serialize(Map<?,?> object,
OutputStream outputStream) |
void |
setJsonObjectMapper(JsonObjectMapper<?,?> jsonObjectMapper)
An
JsonObjectMapper to be used for the conversion to/from
JSON. |
void |
setPacketDeserializer(Deserializer<byte[]> packetDeserializer)
A
Deserializer that will construct the full JSON content from
the stream which is then passed to the JsonObjectMapper. |
void |
setPacketSerializer(Serializer<byte[]> packetSerializer)
A
Serializer that will delimit the full JSON content in
the stream. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
serializeToByteArray
deserializeFromByteArray
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(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(Serializer<byte[]> packetSerializer)
Serializer
that will delimit the full JSON content in
the stream. Default is
ByteArrayLfSerializer
.packetSerializer
- the packetSerializerpublic Map<?,?> deserialize(InputStream inputStream) throws IOException
deserialize
in interface Deserializer<Map<?,?>>
IOException
public void serialize(Map<?,?> object, OutputStream outputStream) throws IOException
serialize
in interface Serializer<Map<?,?>>
IOException