我有一些来自 HubSpot CRM API 的 JSON 数据,在使用 Python 代码进行一些分页之后,基本上看起来像这样:
[
{
"dealId": 18039629,
"portalId": 62515,
"isDeleted": false
},
{
"dealId": 18040854,
"portalId": 62515,
"isDeleted": false
}
]
...现在我想做的是:
1)一次读取一组“JSON”(意思是 dealId、portalId、isDeleted)
2)如果isDeleted==false
然后抓取dealId
andportalId
并存储在变量中
3)使用上面 #2 中的变量来构建一个 URL 字符串,该字符串可用于返回 HubSpot API 并获取有关每笔交易的信息(此 API 端点是https://api.hubapi.com/deals/v1/deal/23487870?hapikey=demo(上面的 JSON 来自哪里23487870
)dealId
4
)将该单独的交易级别信息组合到另一组 JSON 中。具体来说,我想从如下所示的 JSON 中 获取/properties/dealname/value
和获取:properties/dealstage/value
{
"portalId": 62515,
"dealId": 23487870,
"isDeleted": false,
"properties": {
"dealname": {
"value": "AutomationTestUser-national",
"timestamp": 1457692022120
},
"dealstage": {
"value": "appointmentscheduled",
"timestamp": 1457692022120
}
},
"imports": []
}
5) 然后以 JSON 格式输出最终结果,如下所示:
{
"deals":
[
{
"portalId": 62515,
"dealId": 23487870,
"isDeleted": false,
"properties": {
"dealname": {
"value": "AutomationTestUser-national",
"timestamp": 1457692022120
},
"dealstage": {
"value": "appointmentscheduled",
"timestamp": 1457692022120
}
},
"imports": []
},
{
"portalId": 62515,
"dealId": 23487871,
"isDeleted": false,
"properties": {
"dealname": {
"value": "AutomationTestUser-regional",
"timestamp": 1457692022120
},
"dealstage": {
"value": "appointmentscheduled",
"timestamp": 1457692022120
}
},
"imports": []
}
]
}
...全部在 Python 中。
有什么帮助吗?