Label nodes error in Model.toJson

Hi,

I’m creating label nodes to use on links in the following way,

I also use binding in the link template to bind the “link” property to “labeledLink”.

That works fine, but when I’m trying to convert the model to json with the Model.toJson function. (myDiagram.model.toJson)
I get the following error for each label node
“go.js:17 ERROR: trying to convert a GraphObject or Diagram or Model or Tool or Layout or UndoManager into JSON text: Link#1245(0.5 days)”

My temporary fix was to unlink the label nodes (set the link property to null) before converting the model to json and than when converting the model from json relink the labels.
That works, but I would like to avoid link and relink every time I use Model.toJson/Model.fromJson.

Is there a better solution to make Model.toJson/Model.fromJson work on label nodes?

Thanks,

Dor.

There are strict limits on what values Model.toJson and Model.fromJson can handle.
http://gojs.net/latest/intro/usingModels.html#SavingAndLoadingModels

And the whole idea of using a model - view architecture is to make sure there are no references to the view (Diagram/Part/GraphObject) from the model.

Instead of trying to refer to the link (data) in the label node (data), make the reference the other direction. Call GraphLinksModel | GoJS API