StructSerializer.serialize

Dumps/serializes the content of s and its array members, using the given serializer object. The serializer object needs the following methods:

void open ( D, cstring name );

void close ( D, cstring name );

void serialize ( T ) ( D, ref T item, cstring name );

void openStruct ( D, cstring name );

void closeStruct ( D, cstring name );

void serializeArray ( T ) ( D, cstring name, T[] array );

Optional:

void serializeStaticArray ( T ) ( D, cstring name, T[] array );

If this methond doesn't exist, serializeArray will be used.

void openStructArray ( T ) ( D, cstring name, T[] array );

void closeStructArray ( T ) ( D, cstring name, T[] array );

Unfortunately, as some of these methods are templates, it's not possible to make an interface for it. But the compiler will let you know whether a given serializer object is suitable or not

See ocean.io.serialize.JsonStructSerializer for an example.

struct StructSerializer(bool AllowUnions = false)
static
void
serialize
(
S
Serializer
D...
)
(
S* s
,
Serializer serializer
,
ref D data
)

Parameters

S

type of struct to serialize

Serializer

type of serializer object

D

tuple of data parameters passed to the serializer

s S*

struct instance (pointer)

serializer Serializer

object to do the serialization

data D

parameters for serializer

Meta