There is such a json:
{
"id": "1994",
"schedule": {
"1": {
"title": "Понедельник",
"schedule": {
"4": {
"1": {
Full: https://pastebin.com/wLX6D0w
I output schedule['schedule']['1']['schedule'], but how do I get the next key (the json file can change, and the key value too. In this case, it is equal to 4)?
Using an index? How?
CodePudding user response:
I found a solution. This is schedule['schedule'][str(weekday_list.get(dayWeek))]['schedule'].keys()
CodePudding user response:
import json
jsn = {
"id": "1994",
"schedule": {
"1": {
"title": "LOL",
"schedule": {
"4": {
"1": {
}
}
}
}
}
}
# dumping jsn variable from !!!PYTHON!!! dict to string
step_one = json.dumps(jsn)
# loading dumped jsn variable from string to !!!JSON!!!
step_two = json.loads(step_one)
print(step_two['schedule']['1'])
print(step_two['schedule']['1']['schedule'])
print(step_two['schedule']['1']['schedule']['4'])
print(step_two['schedule']['1']['schedule']['4']['1'])