How do I grab a nested value in json?

Viewed 42

I've read numerous "grabbing values from nested values in json api"-esque questions and tried to implement them but my code just doesn't seem to work. i'm getting the usual "keyerror:" type errors. This specific code outputs "IndexError: list index out of range". I am trying to set the value of a variable called "currentUser" to "bob.joe" from value "field_52"

response = requests.request("POST", url, headers=headers)
        responseData = response.json()
        objectsTotal = responseData['objects']
        print(response.text)
        currentUser = responseDat['objects'][6]['data'][1]['field_52']
        print(currentUser)

Here is the json I am trying to parse (only relevant info since sensitive data is in full json)

{
   "totals":{
      "objects":1234,
      "group_totals":0,
      "offset":0,
      "limit":1
   },
   "entity_actions":{
      
   },
   "listing_fields":[
      "field_1",
      "field_5",
      "field_6"
   ],
   "not_viewable":1234,
   "objects":[
      {
         "id":"censored",
         "display_name":"bob.joe",
         "action_objects":[
            {
               
            }
         ],
         "secondary_name":"Bob Joe",
         "display_with_secondary":"Bob.Joe \u003cBob Joe\u003e",
         "field_values":[
            "Bob Joe",
            "Inactive"
         ],
         "data":{
            "field_52":"Bob.Joe",
            "field_1":"Bob Joe",
0 Answers
Related