我正在制作一个django项目。我有一个返回json响应的api请求。随着我得到的json响应,有一个资金来源列表,每个资金来源中都有一个名称与对象相关的项目。我想通过每个json项目并从对象列表中获取名称。如何通过以下响应执行此操作。我还会附上我发送的请求代码......
响应:
{
'funding-sources':[
{
'_links':{
'self':{
'href':'https://api-sandbox.dwolla.com/funding-sources/..546a9720a01',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'funding-source'
},
'customer':{
'href':'https://api-sandbox.dwolla.com/customers/..524dde5a',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'customer'
},
'initiate-micro-deposits':{
'href':'https://api-sandbox.dwolla.com/funding-sources/..6a9720a01/micro-deposits',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'micro-deposits'
}
},
'id':'56b3ab2c-da7b-4edc-83a8-5546a9720a01',
'status':'unverified',
'type':'bank',
'bankAccountType':'checking',
'name':'Cheese',
'created':'2017-11-02T05:37:39.000Z',
'removed':False,
'channels':[
'ach'
],
'bankName':'SANDBOX TEST BANK',
'fingerprint':'..ff1d7dcd22'
},
{
'_links':{
'self':{
'href':'https://api-sandbox.dwolla.com/funding-sources/..a51126e4',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'funding-source'
},
'customer':{
'href':'https://api-sandbox.dwolla.com/customers/..6b56524dde5a',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'customer'
},
'with-available-balance':{
'href':'https://api-sandbox.dwolla.com/funding-sources/..d3a51126e4',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'funding-source'
},
'balance':{
'href':'https://api-sandbox.dwolla.com/funding-sources/..6e4/balance',
'type':'application/vnd.dwolla.v1.hal+json',
'resource-type':'balance'
}
},
'id':'522d3f3c-5ea2-4751-a485-4ad3a51126e4',
'status':'verified',
'type':'balance',
'name':'Balance',
'created':'2017-11-02T01:51:27.000Z',
'removed':False,
'channels':[
]
}
]
}
这里是我现在为请求提供的代码...资金来源位于-embedded对象中,您将在下面的代码中看到:
sources = app_token.get('%s/funding-sources' % account_url)
accounts = sources.body['_embedded']