Model.toJson returns empty diagram

this is my simple diagram :

var diagram = $(go.Diagram, "myDiagramDiv");

diagram.add(
  $(go.Part, "Auto",
    $(go.Shape, "RoundedRectangle", {
      fill: "#fb0"
    }),
    $(go.TextBlock, {
      text: "a Text Block"
    })
  )
);

and my problem is :

diagram.model.toJson()

return empty diagram . the result is :

{ “class”: “go.GraphLinksModel”,
“nodeDataArray”: ,
“linkDataArray”: }

changes (element positions) and elements are not presented in result at all

That is correct and intentional. Your code added an unmodeled Part to the Diagram, so no model was involved. Nor were any templates or data binding.

There are several use cases for unmodeled parts, for example: GoJS Legends and Titles -- Northwoods Software

But using models is the most common and flexible way to create, modify, and persist diagrams: GoJS Using Models -- Northwoods Software

oooh my goodness
thank you so much walter
you’ve made my day :)

i’m thinking that this is worth to be mentioned explicitly in ‘toJson’ api explanations part