So basically my plan for today was to create multiply profiles from json and make them run as a thread. The problem is that I have never done threading but I have read about it and it doesn't feel that complicated but as a first try and also a advice for this could be really useful for me to make something like this possible.
However what I was thinking is to have a json file looking like this:
[{
"Name": "Baller",
"Lastname": "cavs",
"Email": "[email protected]"
},
{
"Name": "Lakers",
"Lastname": "Nation",
"Email": "[email protected]"
}
]
which I hope is correct validated by Json at this moment.
So basically with the json file is that every profile made there should run into a thread that makes the logic into my script but at this moment I just have
{
"Name": "Baller",
"Lastname": "cavs",
"Email": "[email protected]"
}
which only allow once and if I add [ ] to make multiple tasks, I will get a error because it doesn't know what [] are doing... but how do I need to do/think to make it run on a multiple json tasks and to make them run into a thread (I assume thread is the best to go?). What I want it to do is that make each profile into a thread. Do the same logical code in my script/code and then yes.. End when its done pretty much.
Please feel free to comment. I will also edit this by the time I get further!
EDIT:
{
"Profiles": {
"profile1": {
"Name": "Baller",
"Lastname": "cavs",
"Email": "[email protected]"
},
"profile2": {
"Name": "Lakers",
"Lastname": "Nation",
"Email": "[email protected]"
}
}
}
I have changed my Json file into that and what code I have been trying to do is:
with open('profile.json', 'r', encoding='UTF-8') as json_data:
config = json.load(json_data)
Name = config["Name"]
print(Name)
but i'm getting a error saying KeyError: 'Name'
I assume it couldn't find it at all?.. So here i am.. I think what needs to be done is maybe a loop through profiles? But then im thinking like if I do a loop then it will just run 1 by 1 and not all of the profiles at the same time?