Model.toJson doesn't escape double quotes in object keys

Hey Northwoods,

we’re running into an issue where Model.toJson doesn’t escape the double quote character (") in javascript object keys, when used in normal go.ObjectData’s.

Here’s an example that produces the bug for me in latest chrome:

    <div id="diagram" style="width: 100%; height: 90%"></div>
    <script src=""></script>
      const $ = go.GraphObject.make;
      const diagram = $(go.Diagram, {
        div: document.getElementById("diagram"),
        model: $(go.GraphLinksModel, {
          modelData: {
            keyValues: {},

      const obj = { '"': '"' };
      diagram.model.setDataProperty(diagram.model.modelData, "keyValues", obj);

      const json = diagram.model.toJson();

      try {
        // will throw
      } catch (e) {

      // will throw

The problem is toJson returns a string containing {"keyValues":{""":"\""}} where the """ is invalid json. It escapes the object’s value fine ("\""), just doesn’t escape it in the key part.

We’re using version gojs@2.1.50 from npm (and targeting web via webpack), but this happens using the url in my example above as well.

Thanks for pointing out that bug, which has been there forever. It will be easy to fix, but I don’t have a reasonable work-around for you until the next release comes out.

I can confirm that the bug in our app as well as the example code above is now fixed from gojs release

Thanks walter!

Thanks for the confirmation. Sorry for the inconvenience.