How I can get the number of elements in node of JSON data?
JSON:
{
"result":[
{
"run":[
{
"action":"stop"
},
{
"action":"start"
},
{
"action":"start"
}
],
"find":true
}
]
}
I need to get the number of elements from node data['result'][0]['run']
. It should be 3, but I can't find how to do it in Python.
You're close. A really simple solution is just to get the length from the 'run' objects returned. No need to bother with 'load' or 'loads':
len(data['result'][0]['run'])
Source: Stackoverflow.com