Prevent blank attributes from outputting anything

I’m adding a class attribute to the paragraph node using addGlobalAttributes, but when no class has been set the data is still output with a null class value:

[
  {
    "type": "paragraph",
    "attrs": {
      "class": null
    },
    "content": [
      {
        "type": "text",
        "text": "Test"
      }
    ]
  }
]

Is there a way to prevent that, and just have nothing saved if no value is set?

I did find that setting the default to undefined kind of works, but you still end up with an empty attrs object even when there are no other attributes:

[
  {
    "type": "paragraph",
    "attrs": {},
    "content": [
      {
        "type": "text",
        "text": "Test"
      }
    ]
  }
]

Ideally I’d like it to look like this if no class or any other attributes are set:

[
  {
    "type": "paragraph",
    "content": [
      {
        "type": "text",
        "text": "Test"
      }
    ]
  }
]

Attributes defined for a given node always have a value. It seems unproductive to worry about the JSON representation of such a node.

OK no problem. Wanted to check if it was possible but you’re right, it doesn’t really matter.