On Thu, Jul 16, 2020, 2:30 AM Stephen J. Turnbull <turnbull.stephen.fw@u.tsukuba.ac.jp> wrote:
[...]

 > How do I use JSON to serialise an arbitrary instance of some class?

Ask Wes Turner about semantic JSON or whatever it is he frequently
advocates for providing more type information to JSON codecs.

"Re: Improvement: __json__" (2020-04)
https://mail.python.org/archives/list/python-ideas@python.org/thread/ISSUQVYI5OYYXKELUNCD5YCEDZ75LCEB/
https://mail.python.org/archives/list/python-ideas@python.org/message/D7WZX6AGC2OP3G6IYI36LACABQCWTS4J/


 > How do I know which other serialisation format is right?

That's your problem.  We can advise you once you present your
application and threat model(s).  It does depend on both.

If you're sharing data across process and/or system boundaries, pickle is the wrong format. (As evidenced by pyro4/5 completely removing pickle from their library for remote objects for security reasons).