Всем привет!
Есть json-объект:
{
"full": {
"background": {
"type": "background",
"texture_file": "full/bg/background.jpg",
"rect_x": 0,
"rect_y": 0
}
},
"wide": {
"background": {
"type": "background",
"texture_file": "wide/bg/background.jpg",
"rect_x": 0,
"rect_y": 0
}
},
"walls": {
"wall_0": {
"texture_file": "walls/wall_0.png",
"rect_x": 0,
"rect_y": 500
},
"wall_1": {
"texture_file": "walls/wall_0.png",
"rect_x": 64,
"rect_y": 500
},
"wall_2": {
"texture_file": "walls/wall_0.png",
"rect_x": 128,
"rect_y": 500
},
"wall_3": {
"texture_file": "walls/wall_0.png",
"rect_x": 192,
"rect_y": 500
},
"wall_4": {
"texture_file": "walls/wall_0.png",
"rect_x": 256,
"rect_y": 500
},
"wall_5": {
"texture_file": "walls/wall_0.png",
"rect_x": 320,
"rect_y": 500
}
}
}
Как мне рекурсивно получить доступ к объектам «wall_n». Итератор типа:
...
json_obj = json.load(my_data)
wall_loop = 0
for wall in json_obj["walls"]:
print(wall["wall_%s" % wall_loop])
wall_loop += 1
Не работает