Description
Our Metadata
ABC defines to_dict
and from_dict
, and we use these methods to recursively read and write nested metadata documents to and from JSON. This would be fine if every implementation of Metadata
serialized to a JSON object, but dtypes are a case where we have a rich in-memory representation that serializes to a simple string. data_type.to_dict() -> str
is pretty confusing in this case, since one would expect to_dict
to return a dict.
Since Metadata
is a dataclass, someone who wants to recursively turn one into a dict can already use dataclasses.asdict
. So maybe we should remove from_dict
and to_dict
, and instead define from_json
and to_json
, methods that turn a metadata model into a JSON-serializable form. This would make the job of these methods more obvious I think, and remove the confusing situation where to_dict
doesn't produce a dict.