Serialiser.serialise

Serialises the given value, using the provided parent.

Non-Struct & Non-Array types: By default, these types of data are stored as child objects to the parent, holding a single value. For example the field string name would become an ArchiveObject called name, holding a single string value.

A single field can be marked as @MainValue to become the value of the parent object.

While binary archives may support multiple values under an object, text-based ones may only allow a single value, which i s what @MainValue will be used for. Everything else must be an attribute or child object.

Multiple fields can be marked as @Attribute to be used as an attribute. For example, the field @Attribute string name would be added to the parent as an attribute called 'name', holding a string value.

Multiple fields can be given the @Name UDA, and the @Setting UDA. Please see their own documentation.

Struct types: Struct types by default create a new child object inside the parent to store their data. Each field in the struct follows the same rules as are being described.

@Setting and @Name can be attached to structs.

Array types (for non-structs): By default, these types of arrays will be stored as a child object in the parent, where all of the array's values are given to the child object.

This type of array can be used as the @MainValue for a struct.

@Setting and @Name (more in the 'Array types (shared)' section) are of course supported as well.

Array types (for structs): By default, these types of arrays will write out all of the struct child objects directly into the parent. However, the settings Serialiser.Settings.ArrayAsObject can be used to store these children into a seperate child object. Please refer to it's documentation.

@Setting and @Name are supported.

Array types (shared): The names chosen when serialising arrays (and other types in general) is a bit complicated, so please refer to the documentation for getFieldName.

Nullable: If the value is currently null, then nothing about it is serialised.

class Serialiser
static final
void
serialise
(
T
)

Parameters

data T

The data to serialise.

parent ArchiveObject

The parent to serialise the data into.

Meta