0

Given the json payload below, how do I get the value of 'hotspot' using Python 3.x? The top level seems to be a a dict with one key value pair. 'Recs' is the key and the value is a Python list. I have loaded the json payload into the Python class using json.loads(payload).

json payload:

{
    'Recs': [{
        'eSrc': 'big-a1',
        'reqPs': {
            'srcIP': '11.111.11.111'
        },
        'a1': {
            'a1Ver': '1.0',
            'obj': {
                'eTag': '38f028e',
                'sz': 1217,
                'seq': '02391D2',
                'hotspot': 'web/acme/srv/dev/8dd'
            },
            'confId': 'acme-contains',
            'pipe': {
                'name': 'acme.dev',
                'oId': {
                    'pId': 'BDAD'
                }
            }
        }
    }]
}

1 Answer 1

1

{ indicates a dict, [ indicates a list so hotspot is at:

my_json['Recs'][0]['a1']['obj']['hotspot']
Sign up to request clarification or add additional context in comments.

2 Comments

What is the [0] for between ['Recs'] and ['a1']?
Recs starts with [ so it is a list, [0] selects first element of the list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.