How to export myDiagram to a json file

1.How to export myDiagram to a json file, then I can import the json file into another myDiagram?
2.How to save all the myDiagram infos into mysql,then I can load data from DB to redraw?(include position ,layout, color, node, data and so on)

As many of the samples demonstrate, just call myDiagram.model.toJson() and save that string, and later get that string and call myDiagram.model = go.Model.fromJson(str).

How you save and later retrieve that string depends on your environment. For web apps it is commonplace for the web server to do that work.

And what information is saved in that string depends on what properties you have stored on the node data objects in your model. Please read Get Started with GoJS and GoJS Introduction -- Northwoods Software.

Thank you very much.
I know what you’re talking about.
What I really want is the model include postion, layout, even color of every node.
In other words, when I reload model from the file I have saved, it shoud be the same as before.
Is that possible?

Just make sure that your templates have the data bindings that you want.
https://gojs.net/latest/intro/usingModels.html
https://gojs.net/latest/intro/dataBinding.html