Python | How to parse JSON from results from AWS response? Python | How to parse JSON from results from AWS response? json json

Python | How to parse JSON from results from AWS response?


As per the boto3 docs [http://boto3.readthedocs.io/en/latest/reference/services/elasticbeanstalk.html?highlight=describe_instances_health#ElasticBeanstalk.Client.describe_instances_health], the describe_instances_health method returns dict and not json. Hence, there is no need for you to do the conversion. To get VersionLabel from data, use -

data ['InstanceHealthList'][0]['Deployment']['VersionLabel']

Edit : Note that the above fetches the VersionLabel for the first instance, out of possible multiple instances. In case you have multiple instances and they happen to have different values of VersionLabel, then you would require additional logic to get the one you need.


just incase the ask is to convert the boto response into a legal json format -

import jsonresponse_json = json.dumps(response, default=str))

datetime.datetime needs to be handled during the dict to json conversion