importjsonfromdatetimeimportdatetimefromgroupdocs.assemblyimportDataSourceInfo,DocumentAssemblerdefparse_dates(item):# JSON has no dates: turn the order dates into datetime objects for the templateforkeyin("OrderDate","ShippingDate"):ifkeyinitem:item[key]=datetime.strptime(item[key],"%Y-%m-%dT%H:%M:%S")returnitemwithopen("customers.json",encoding="utf-8")asf:customers=json.load(f,object_hook=parse_dates)assembler=DocumentAssembler()assembler.assemble_document("common-master-detail.msg","common-master-detail-report.msg",[DataSourceInfo(customers,"customers"),DataSourceInfo("Harbor Lane Provisions <orders@harborlane.example>","sender"),DataSourceInfo(["Quayside Bistro <orders@quaysidebistro.example>","jonas.weber@harborlane.example"],"recipients"),DataSourceInfo("amara.osei@harborlane.example","cc"),DataSourceInfo("Common master detail","subject"),])