Is there a way to use something like JSON?
Pickles are a bad idea. pickle — Python object serialization — Python 3.10.2 documentation says:
It is possible to construct malicious pickle data which will execute arbitrary code during unpickling. Never unpickle data that could have come from an untrusted source, or that could have been tampered with.