On Friday, November 18, 2016 at 1:23:18 PM UTC-5, mike....@gmail.com wrote: > hi all, > > Im reading in a JSON file that looks like this > > > [ > { > "name":"myField1", > "searchable":true, > "navigable":true, > "custom":true, > "clauseNames":[ > "cf[10190]", > "Log Details" > ], > "orderable":true, > "id":"customfield_10190", > "schema":{ > "customId":10190, > "type":"string", > "custom":"com.atlassian.jira.plugin.system.customfieldtypes:textarea" > } > }, > { > "name":"myField2", > "searchable":true, > "navigable":true, > "custom":true, > "clauseNames":[ > "cf[10072]", > "Sellside Onboarding Checklist" > ], > "orderable":true, > "id":"customfield_10072", > "schema":{ > "items":"option", > "customId":10072, > "type":"array", > > "custom":"com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes" > } > }] > > > Lets say I want to get the ID # of MyField1, how can I parse this with json > lib? Theyre all on the same level, not sure how to target it to go to > MyField1 and get "id" value. > > Thanks
thanks everyone for the feedback, i got it to work like this using multi-dim dictionary # get JSON to parse url = "https://"+jira_server+"/rest/api/2/field" req = requests.get(url,auth=(jira_user,jira_pw), verify=False) jsonfile = req.json() # save as key,val pair file cf = {} for item in jsonfile: name = item.get("name") fid = item.get("id") cf[name] = { 'id' : fid } with open(base_dir+'/fields.json','w') as f: json.dump(cf,f) -- https://mail.python.org/mailman/listinfo/python-list