I want to get the data of json folders using Python 3.7.2.
This is my json file:
{"device":
[
{"name": "device1", "status": 0},
{"name": "device2", "status": 1},
{"name": "device2", "status": 1}
]
}
For my project I need following variables:
variable of all devices gathered in a list:
devices = ["device1", "device1", "device1"]
status of devices saved in different variables:
status_device1 = 0 status_device2 = 1 status_device3 = 1
It is possible to change the structure of the json file, but it has to be only one json file, so I need something like:
jdevices = getDevices(json_data) | Output: {'device1', 'device2', 'device3'}
and:
jstatus = getStatus(json_data, "device1") | Output: 0