HTML5's custom attributes minigotcha

I was trying to set a Javascript Object as the value for a custom attribute, but I was just getting "[Object object]" as the value when reading it back. This is actually the toString() version of my object, and was also my 'fault' for not reading the specs (or for daring to attempt something risky!), as the custom attributes can only contain strings:

element . dataset Returns a DOMStringMap object for the element's data-* attributes.
(# source)

[...] The custom data attributes is transformed to a key for the DOMStringMap entry [...]
(# source)

Or more specifically, only 'DOMStrings' are allowed.