object_serialization library

A serialization library that supports circular references and preserves identity when objects are referenced via multiple paths.

This library provides the ObjectSerialization class that can be used to encode and decode objects to and from JSON strings. Classes that implement or extend Serializable can handle custom serialization and deserialization.

This library's primary benefit is that it can handle circular references and preserves object identity so that an object referenced from multiple places in the object graph is only serialized once.

Classes

ObjectSerialization
This class that provides static methods to encode and decode objects to and from JSON strings.
Serializable
This is an interface that classes can implement or inherit to handle custom serialization and deserialization. Classes that implement Serializable must provide a factory constructor that takes a list of final properties. The final properties are the properties that are not transient and are required to create the object. The transient properties are set separately after the object is created.

Typedefs

FactoryFunction = Serializable Function(List finalProperties)
When decoding a JSON string, the ObjectSerialization class uses factory functions to create objects of specific types. The factory functions are provided as a map where the keys are the type names and the values are functions that create objects of that type.