serialization :: Serializer :: serialize
object
This method, and refinements, should handle null
and probably
use double dispatch to customize the bahavior per serializable objects.
# Entry point method of this service, serialize the `object`
#
# This method, and refinements, should handle `null` and probably
# use double dispatch to customize the bahavior per serializable objects.
fun serialize(object: nullable Serializable) is abstract
lib/serialization/serialization_core.nit:57,2--61,57
redef fun serialize(object)
do
if object == null then
stream.write "null"
else
if current_object == null then
first_object = object
end
var last_object = current_object
current_object = object
object.accept_inspect_serializer self
current_object = last_object
end
end
lib/serialization/inspect.nit:34,2--48,4
redef fun serialize(object)
do
if object == null then
stream.write "null"
else
if plain_json then
for o in open_objects do
if object.is_same_serialized(o) then
# Cycle, can't be managed in plain json
warn "Cycle detected in serialized object, replacing reference with 'null'."
stream.write "null"
return
end
end
open_objects.add object
end
first_attribute = true
var last_object = current_object
current_object = object
object.accept_json_serializer self
first_attribute = false
current_object = last_object
if plain_json then open_objects.pop
end
end
lib/json/serialization_write.nit:74,2--101,4
redef fun serialize(object)
do
if object == null then
stream.write_msgpack_null
else
if plain_msgpack then
for o in open_objects do
if object.is_same_serialized(o) then
# Cycle, can't be managed in plain_msgpack mode
warn "Cycle detected in serialized object, replacing reference with 'null'."
stream.write_msgpack_null
return
end
end
open_objects.add object
end
var last_object = current_object
current_object = object
object.accept_msgpack_serializer self
current_object = last_object
if plain_msgpack then open_objects.pop
end
end
lib/msgpack/serialization_write.nit:84,2--109,4