Feb-03-2023, 08:13 PM
By "scenes" do you mean these?
The dictionary has a key['states']. It appears to be the only key in the dictionary.
The value for 'states' is a list. In the example you posted, the list length is 1.
json_data['states'][0] is another dictionary. From your posted file it too appears to have only one key, 'state'.
json_data['states'][0]['state'] is another list. I think this list are the 'scenes' you mention.
Output:{'id': ['0'], 'tempValue': ['2000'], 'dhw': ['1']}
{'id': ['1'], 'tempValue': ['1900'], 'dhw': ['1']}
{'id': ['2'], 'tempValue': ['1700'], 'dhw': ['1']}
{'id': ['3'], 'tempValue': ['1800'], 'dhw': ['1']}
{'id': ['4'], 'tempValue': ['1000'], 'dhw': ['1']}
I got those like this:import json with open("test.txt", "r") as file: json_data = json.load(file) states = json_data["states"][0]["state"] print(*states, sep="\n")The top level of your json file is a dictionary.
The dictionary has a key['states']. It appears to be the only key in the dictionary.
The value for 'states' is a list. In the example you posted, the list length is 1.
json_data['states'][0] is another dictionary. From your posted file it too appears to have only one key, 'state'.
json_data['states'][0]['state'] is another list. I think this list are the 'scenes' you mention.