json dump and load a script with variables

Hi! I have a seperate script in my .blend’s directory called gamesystem.py. There are multiple classes(for multiple tasks) that each contains a lot of variables(they’re different - integers, floaters, dictionaries etc.). I need to save all of that data using json dump function and than load it. However, I don’t know how do I store all of that data in a single dictionary. Could anybody help? I need both - saving and loading help as I am confused in both!

Today is last BGMC day and I need this now. Anyone, please, help me!!! (I am geting desperated)

I dont use Json anymore becuase it doesnt encrypt the data. Heres something simple i had from when I was learning. You can hopefully figure out whats going on, and it could be cleaned up a bit, as some lines are basically redundant. It will create the my.txt file in the current directory. Hopefully you can see how its overwring old values with new values in the file.



import bge
import json
from bge import logic
controller = logic.getCurrentController()
owner = controller.owner
key = logic.keyboard.events


thisscene =  logic.getCurrentScene()




owner["speed"] = 10   #play with this within a blend to see how it loads and writes
owner["newspeed"] = 0   #play with this within a blend to see how it loads and writes  


###READ
if key[bge.events.RKEY] ==1:
    with open(bge.logic.expandPath("//my.txt"), 'r') as file:
        logic.myfile = json.load(file)
        owner["speed"] = logic.myfile['speed']
    




###WRITE
if key[bge.events.WKEY] ==1:
    with open(bge.logic.expandPath("//my.txt"), 'w') as file:
       logic.myfile['speed'] = owner['newspeed']
       json.dump(logic.myfile, file)
       owner["speed"] = logic.myfile['speed']
    









Write to the file first so you can see the JSON file syntax

I am having an online lesson now where I found everything out about this thing. Soon I will be educated;)