I am successfully parsing an api in square brackets with a single name
API output :
{u'energyDetails':
{u'timeUnit': u'DAY',
u'meters':
[{u'values':
[{ u'date': u'2022-08-30 00:00:00',
u'value': 64225.0}],
u'type': u'FeedIn'}],
u'unit': u'Wh'}}
with this command :
FeedIn = parsed_power['energyDetails']['meters'][0]['values'][0]['value']
I must add [0] becouse i have square bracket.....
How can i parse API with multiple value ( same name ) API output
{"energyDetails":
{"timeUnit":"DAY",
"unit":"Wh",
"meters":
[{"type":"FeedIn","values":
[{"date":"2022-08-30 00:00:00",
"value":64225.0}]},
{"type":"SelfConsumption","values":
[{"date":"2022-08-30 00:00:00",
"value":15478.0}]}]}}
Thankyou for help
You can get a list of values with something like this:
Or maybe you want to get each value by index: simply use
[1]instead of[0]and so on.And if you can have multiple values for each metric, you may want a list like this: