core :: Reader :: deserialize_msgpack
nullable Object
from MessagePack formated dataThis method use metadata in the MessagePack source to recreate full
Nit objects serialized by Writer::serialize_msgpack
or
MsgPackSerializer
.
The dynamic type of the deserialized object can be limited to static_type
.
Warning: Deserialization errors are reported with print_error
,
the returned object may be partial or fall back on null
.
To handle the errors programmatically, use a MsgPackDeserializer
.
# Deserialize full Nit `nullable Object` from MessagePack formated data
#
# This method use metadata in the MessagePack source to recreate full
# Nit objects serialized by `Writer::serialize_msgpack` or
# `MsgPackSerializer`.
#
# The dynamic type of the deserialized object can be limited to `static_type`.
#
# Warning: Deserialization errors are reported with `print_error`,
# the returned object may be partial or fall back on `null`.
# To handle the errors programmatically, use a `MsgPackDeserializer`.
fun deserialize_msgpack(static_type: nullable String): nullable Object
do
var deserializer = new MsgPackDeserializer(self)
var res = deserializer.deserialize(static_type)
if deserializer.errors.length == 1 then
print_error deserializer.errors.join("")
else if deserializer.errors.not_empty then
print_error "Deserialization Errors:\n* {deserializer.errors.join("\n* ")}"
end
return res
end
lib/msgpack/serialization_read.nit:53,2--76,4