Class

JSONSerializer

JSONSerializer()

Constructor

# new JSONSerializer()

Concrete implementation of a Serializer in JSON format

JS's native JSON.stringify (used here) is not deterministic and therefore should not be used for hashing purposes

To keep dependencies low, we will not implement this, but we recommend implementing a similar JSONSerializer using 'deterministic-json' libraries

Implements:

View Source utils/serialization.ts, line 6

Methods

# deserialize(str) → {T}

Rebuilds a model from a serialization

Parameters:
Name Type Description
str string
Implements:

View Source utils/serialization.ts, line 119

If it fails to parse the string, or to build the model

Error
T

# protected preSerialize(model)

prepares the model for serialization

returns a shallow copy of the object, containing an enumerable ModelKeys#ANCHOR property so the object can be recognized upon deserialization

Parameters:
Name Type Description
model T

View Source utils/serialization.ts, line 110

# serialize(model) → {string}

Serializes a model

Parameters:
Name Type Description
model T
Implements:

View Source utils/serialization.ts, line 128

if fails to serialize

Error
string