fromJson static method

Model fromJson(
  1. Object s, [
  2. Model? model
])

This static function parses a string in JSON format that was written by Model#toJson, and then constructs, initializes, and returns a model with that information.

Note that properties with values that are functions are not written out by #toJson, so reading in such a model will require constructing such a model, initializing its functional property values, and explicitly passing it in as the second argument.

In order to serialize instances of some classes and enumerated values and some other cases, Model#toJson writes out special Objects that this Model.fromJson function substitutes with the intended values. Those special objects will have a property named "class" whose value will be one of the special substitution cases: "NaN", "Date", "go.EnumValue", "go.Point", "go.Size", "go.Rect", "go.Margin", "go.Spot", "go.Brush", "go.Geometry".

As a special case when deserializing an object, if the property is named "points" and the property value is an Array with an even number of numbers, it will substitute a List of Points.

Typical usage:

var modelAsText = ...;  // fetch the model in textual format from a database
myDiagram.model = go.Model.fromJson(modelAsText);

Implementation

static _i3.Model fromJson(
  _i2.Object s, [
  _i3.Model? model,
]) =>
    _i4.callMethod(
      _declaredModel,
      'fromJson',
      [
        s,
        model ?? _i5.undefined,
      ],
    );