How to extract nested JSON data?

后端 未结 4 2033
野的像风
野的像风 2020-12-07 06:23

I am trying to get a value from a data JSON. I have successfully traversed deep into the JSON data and almost have what I need!

Running this command in Python :

4条回答
  •  醉话见心
    2020-12-07 06:59

    You could also use glom it's great for deeply nested functions and has sooo many uses that make complicated nested tasks easy.

    For example translating @Celius's answer:

    glom(A, 'Tags.1.Value')
    

    Returns the same thing:

    CodeDeploy_Ernie-dev-Autoscaling-Deploy_d-4WTRTRTRT
    

    So to answer your original question you'd use:

    glom(response, 'Reservations.0.Instances.0.Tags.1.Value')
    

提交回复
热议问题