如何使用 python 遍历这个嵌套的 json 数组

How to iterate through this nested json array with python

所以我向 JIRA 发出了 API 调用以获取所有问题的列表。它 returns 像这样:

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

我正试图找到里面的东西 fields。 这是我拥有的:

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

然后:

response['issues'] 有效。但是我找不到访问 fields 然后访问其中元素的方法。我考虑过迭代,但不确定是否有更简单的解决方案。

我的理解是 response[issues] 是一个列表,我知道如何访问它的每个元素 response[issues][0] 但是如何访问嵌套在列表中的对象? (仍在研究中——可能会找到答案)

如果您查看 json,它是一个哈希数组或字典列表。要获取字段,您只需调用第一个数组元素和键即可。

response[issues][0][fields]