To represent an arbitrarily complex
data structure in a location-independent way so that it can be
communicated or stored elsewhere.
For example, an
object representing a time, with
attributes for year, month, timezone, etc., could be
serialised as the
string "2002-02-24T14:33:52-0800", or an
XML element "<dateobj year='2002' month='02' day='24'
hour='14' minute='33' second='52' timezone='-0800' />", or as
a
binary string.
As well as providing an external data representation
(e.g. representing an
integer as a string of
ASCII
digits) and
marshalling components into a single block of
data, a serialisation
algorithm needs to follow
pointers
to include objects referred to by the initial object. This is
further complicated by the possible presence of cycles in the
object graph.
It should be possible to store the serialised representation
on disk, or transmit it across a network, and then restore it
as an object (graph) that is the same as the original.