Package io.ably.lib.objects
Interface LiveObjectSerializer
public interface LiveObjectSerializer
Serializer interface for converting between LiveObject arrays and their
MessagePack or JSON representations.
-
Method Summary
Modifier and TypeMethodDescription@NotNull com.google.gson.JsonArray
asJsonArray
(@NotNull Object[] objects) Serializes the given Object array as a JSON array.@NotNull Object[]
readFromJsonArray
(@NotNull com.google.gson.JsonArray json) Reads a JSON array from the givenJsonArray
and deserializes it into an Object array.@NotNull Object[]
readMsgpackArray
(@NotNull org.msgpack.core.MessageUnpacker unpacker) Reads a MessagePack array from the given unpacker and deserializes it into an Object array.void
writeMsgpackArray
(@NotNull Object[] objects, @NotNull org.msgpack.core.MessagePacker packer) Serializes the given Object array as a MessagePack array using the provided packer.
-
Method Details
-
readMsgpackArray
@NotNull @NotNull Object[] readMsgpackArray(@NotNull @NotNull org.msgpack.core.MessageUnpacker unpacker) throws IOException Reads a MessagePack array from the given unpacker and deserializes it into an Object array.- Parameters:
-
unpacker
- the MessageUnpacker to read from - Returns:
- the deserialized Object array
- Throws:
-
IOException
- if an I/O error occurs during unpacking
-
writeMsgpackArray
void writeMsgpackArray(@NotNull @NotNull Object[] objects, @NotNull @NotNull org.msgpack.core.MessagePacker packer) throws IOException Serializes the given Object array as a MessagePack array using the provided packer.- Parameters:
-
objects
- the Object array to serialize -
packer
- the MessagePacker to write to - Throws:
-
IOException
- if an I/O error occurs during packing
-
readFromJsonArray
Reads a JSON array from the givenJsonArray
and deserializes it into an Object array.- Parameters:
-
json
- theJsonArray
representing the array to deserialize - Returns:
- the deserialized Object array
-
asJsonArray
Serializes the given Object array as a JSON array.- Parameters:
-
objects
- the Object array to serialize - Returns:
- the resulting JsonArray
-