Sep-19-2019, 07:46 PM
The Python documentation on JSON reads, "This simple serialization technique can handle lists and dictionaries, but serializing arbitrary class instances in JSON requires a bit of extra effort. The reference for the json module contains an explanation of this." But I can't seem to find the explanation in the JSON reference. I'm very new to programming, so it's probably there; it just went right over my head.
The reason I need to serialize the objects of a class I created is that I'm making a random NPC generator for tabletop RPGs, and each generated NPC is an instance of my NPC class with semi-randomized characteristics. Users will want to save the ones they like.
So how does one serialize a custom class object with JSON?
Thanks in advance.
The reason I need to serialize the objects of a class I created is that I'm making a random NPC generator for tabletop RPGs, and each generated NPC is an instance of my NPC class with semi-randomized characteristics. Users will want to save the ones they like.
So how does one serialize a custom class object with JSON?
Thanks in advance.