I'm trying to iterate through this json array :
[{
"date": "2018-02-21T12:53:00",
"name": "System date",
"ID_BBData": "none",
"TOKEN_BBData": "none",
"rawValue": 540916682
},
{
"date": "2018-02-21T12:53:00",
"name": "Temperature sensor 1",
"ID_BBData": "none",
"TOKEN_BBData": "none",
"rawValue": 11
},
{
"date": "2018-02-21T12:53:00",
"name": "Value week",
"ID_BBData": "none",
"TOKEN_BBData": "none",
"rawValue": 1810
}]
With this loop :
# print the keys and values
for key in jsonObject:
value = jsonObject[key]
print("The key and value are ({}) = ({})".format(key, value))
Where jsonObject is the json above. The problem is that the json is enclosed by [] but there isn't any name to this array.
Any clue to iterate through this one ?
Thanks a lot !
[]JSON" isjsonObject, no? It's a list. Iterating over a list yields the individual list items, not the keys.listsfor json arrays,dictsfor json objects, etc. So what you have here is a Pythonlistof Pythondicts. Now you can learn how to iterate over a Pythonlistand how to use a Pythondict(both being required skills if you hope to do anything with Python).