简体   繁体   中英

How to iterate through this nested json array with python

So I made an API call to JIRA to get the list of all the issues. It returns something like this:

{
 issues: [
  {
    fields: {
         description: 
         summary: 
         creator:
         reporter:
         priority:
       }
     }
   ]

and I'm trying to get to what's inside fields . Here's what I have:

response = requests.get(url + '/search?jql=resolution%20=%20Unresolved%20order%20by%20priority%20DESC,updated%20DESC', auth=auth).json()

and then :

response['issues'] works. But I can't find a way to access fields and then the elements inside it. I thought about iterating through but not sure if there's a simpler solution.

My understanding is that response[issues] is a list and I know how to access each element of it response[issues][0] but how to access the object nested inside the list? (still researching on it -- might find an answer)

if you look at your json it's an array to a hash or list to dict. To get fields you'd just call the first array element and the key.

response[issues][0][fields]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM