this in that context is not well defined and you shouldn’t be using it. You are not defining something on the Diagram’s prototype so this is just whatever it was in the outside scope, or potentially nothing.
You could try making a closure:
var self = this; // if you are sure of what 'this' is here
console.log("network : ", myDiagram.model.toJson());
No GoJS event listeners or functional properties ever have this bound when called. That’s because when we designed the API we knew that some day there would be “arrow functions”. Although at the time I don’t think we even knew about the syntax or that they would be called “arrow functions”. It’s been too long for me to remember…
The only functions that have this bound are methods of classes, some of which may be overridden.