0

I have JSON and can get value using

print(step_id['Steps'][0]['Id'])

But the position of Id key might be changed. However, its name 'Id' won't change.

How to get value by using a key name? Prompt me, please.

Example of JSON file

{
    "Steps": [
        {
            "Id": "UPSKGVQL6Y",
            "Config": {
                "Properties": {},
                "Args": []
            },
            "Status": {}
        }
    ],
    "ResponseMetadata": {}
}

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • What are the other locations where `Id` might be? In other dicts in the `Steps` list? – MattDMo Nov 08 '22 at 17:28
  • 1
    Loop through the array, and check if the dictionary has an `Id` key. – Barmar Nov 08 '22 at 17:28
  • Can you show an example where it's not in the `0` index? – Barmar Nov 08 '22 at 17:29
  • Does this answer your question? [Find object in list that has attribute equal to some value (that meets any condition)](https://stackoverflow.com/questions/7125467/find-object-in-list-that-has-attribute-equal-to-some-value-that-meets-any-condi) – 0stone0 Nov 08 '22 at 17:30

0 Answers0