[英]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. 因此,我对JIRA进行了API调用,以获取所有问题的列表。 It returns something like this:
它返回如下内容:
{
issues: [
{
fields: {
description:
summary:
creator:
reporter:
priority:
}
}
]
and I'm trying to get to what's inside fields
. 而且我正在尝试探究
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. response['issues']
有效。 But I can't find a way to access fields
and then the elements inside it. 但是我找不到访问
fields
然后访问其中的元素的方法。 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? 我的理解是response [issues]是一个列表,我知道如何访问其中的每个元素
response[issues][0]
但是如何访问嵌套在列表中的对象? (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. 如果您查看自己的json,则是一个哈希数组或字典列表。 To get fields you'd just call the first array element and the key.
要获取字段,您只需调用第一个数组元素和键。
response[issues][0][fields]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.