hey folks, do we have a policy around implementing...
# development
c
hey folks, do we have a policy around implementing serialisation? in my work on dumping source analysis for python, I'm dumping a lot of our classes. Dataclasses has a builtin
dataclasses.asdict
, which works well enough for dataclasses, but many of our types aren't (json) serialisable. Do we have a standard way of doing this? Should I write custom
serialisable
methods? make a custom encoder for JSON?
h
We’ve used a custom
JSONEncoder
in a few places, so I guess that?
👍 1
f
We don't really seem to have a standard. For example, in the BSP rules, I ended up writing hand-coded
to_json_dict
and
from_json_dict
for many of the dataclasses (since the JSON format for BSP has differing case requirements).
👍 1
c
sounds good. A custom JSONEncoder would be nice, not having to write
str(address)
every time would be nice. We might also want to centralise that, the other source-analysis plugins have an ad-hoc serialiser inside of the rule. maybe having a method/subclass for Console.