Oct-12-2023, 12:27 AM
(This post was last modified: Oct-12-2023, 03:41 AM by foxholenoob.)
I apologize, the insert code snippet button isn't working.
I am having an issue dumping to json and then reading back in. When I read it back in correctly. In the screenshot you can see visual studio indicating the object is slightly different and when I try to do a for loop through my list it sees the value of "maps" as part of the map list.
My best guess is that I am reading the json back in and its not converting it back to the object correctly.
Here is the code I am using to dump the object to JSON:
I am having an issue dumping to json and then reading back in. When I read it back in correctly. In the screenshot you can see visual studio indicating the object is slightly different and when I try to do a for loop through my list it sees the value of "maps" as part of the map list.
My best guess is that I am reading the json back in and its not converting it back to the object correctly.
Here is the code I am using to dump the object to JSON:
fxWarListDump = json.dumps(fxWarConquest.fxWarMaps.maps, default=lambda x: x.__dict__, indent=4) with open(fxWarMapList, "w") as outfile: outfile.write(fxWarListDump)Here is the code I am using to read the JSON back in:
with open(fxWarMapList, 'r') as j: fxWarConquest.fxWarMaps.maps = json.loads(j.read())