I have a dictionary that contains references to different functions. I was trying to make my code more readable and make it easier to add functions to this dictionary. I was trying to convert my dictionary into a .json file but it gives an error once it tries to add the function.
This is a simplified version of my code:
import json
def func1(): print("func1")
def func2(): print("func2")
def func3(): print("func3")
testDict = {
"value1":[func1, "test1"],
"value3":[func2, "test2"],
"value3":[func3, "test3"],
}
with open("test.json", "w") as fw:
json.dump(testDict, fw, indent=2)
This is the code i made to read the .json file:
with open("test.json", "r+") as fr:
testDict2 = json.load(fr)
However when i try to create the file it stops once it reaches the reference to the first function:
{
"value1": [
How do i fix this and is it even possible?