mc.utils.Serialization

December 17, 2022 ยท View on GitHub

This namespace provides utilities for serializing and deserializing objects.


Functions

serialize

The serialize function takes an object as input and returns an associative array representation of that object. If the object is a roSGNode, it calls the serialize method on the node to get its serialized representation. For other types of objects, the serialize method must be provided by the object itself.

Arguments

Argument NameTypeDescription
serializableobjectThe object to be serialized.

Returns

An associative array containing the serialized representation of the object.


deSerialize

The deSerialize function takes an associative array as input and returns an object created from the data in the array. If an optional object is provided, the function will deserialize the data into that object. If no object is provided, a new object will be created based on the data.

Arguments

Argument NameTypeDefault ValueDescription
datamc.types.assocarrayN/AThe associative array containing the serialized representation of the object.
serializableobjectinvalidAn optional object to deserialize the data into. If not provided, a new object will be created based on the data.

Returns

The deserialized object.


isSerializable

This function returns a boolean indicating whether an object is serializable.

Arguments

Argument NameTypeDescription
itemobjectThe object to check for serializability.

Returns

true if the object is serializable, false otherwise