whole file is here:https://1drv.ms/u/s!AizscpxS0QM4hJpFPnbeAexYPwYu9Q
I want from this part:
"subtasks": [
{
"fields": {
"issuetype": {
"avatarId": 10316,
"description": "The sub-task of the issue",
"iconUrl": "https://jira.corp.company.com/secure/viewavatar?size=xsmall&avatarId=10316&avatarType=issuetype",
"id": "10101",
"name": "Sub-task",
"self": "https://jira.corp.company.com/rest/api/2/issuetype/10101",
"subtask": true
},
"priority": {
"iconUrl": "https://jira.corp.company.com/images/icons/priorities/medium.svg",
"id": "3",
"name": "Medium",
"self": "https://jira.corp.company.com/rest/api/2/priority/3"
},
"status": {
"description": "",
"iconUrl": "https://jira.corp.company.com/",
"id": "10000",
"name": "Backlog",
"self": "https://jira.corp.company.com/rest/api/2/status/10000",
"statusCategory": {
"colorName": "blue-gray",
"id": 2,
"key": "new",
"name": "To Do",
"self": "https://jira.corp.company.com/rest/api/2/statuscategory/2"
}
},
"summary": "Remove user account in Local AD"
},
to extract "Remove user account in Local AD"
(summary field)
So far i have this code:
data = json.load(open(1.json))
for issue in data['issues']:
print issue['fields']['subtasks']
and getting section above, how to get only summary value ?
if i add:
for issue in data['issues']:
print issue['fields']['subtasks']['summary']
i get:
print issue['fields']['subtasks']['summary']
TypeError: list indices must be integers, not str
same with:
for i in range (0, len (data['issues'])):
print data['issues']['fields']['subtasks'][i]['fields']['summary']
TypeError: list indices must be integers, not str
See Question&Answers more detail:os