The serializeAll decorator can used on a class to signal that all primitive properties, or complex properties with a name matching a pattern, should be serialized automatically.
serializeAll
pattern
@serializeAllclass Store { a = 3 b}const store = new Store()store.c = 5store.d = {}serialize(store) // { "c": 5 }
class DataType { @serializable x @serializable y}@serializeAll(/^[a-z]$/, DataType)class ComplexStore {}const store = new ComplexStore()store.a = {x: 1, y: 2}store.b = {}store.somethingElse = 5serialize(store) // { a: {x: 1, y: 2}, b: { x: undefined, y: undefined } }
Generated using TypeDoc
The
serializeAll
decorator can used on a class to signal that all primitive properties, or complex properties with a name matching apattern
, should be serialized automatically.Example
Example