无法从 Sendgrid 模板中的键获取值

Unable to get a value from the key in Sendgrid template

我正在尝试获取一个值并在 sendgrid 电子邮件模板中使用它。 JSON 看起来像这样。

“productskummapping”:{ “created/updated”:2, “失败”:0 }

{{productskumapping.created/updated}} 在电子邮件模板中没有给出任何值。宏不会被替换。但是宏必须替换为 2。如何使它工作?斜杠字符(“/”)导致了问题。请为此提出任何解决方案。

此处为 Twilio SendGrid 开发人员布道师。

SendGrid 使用 handlebars 样式表达式来插入数据。我刚刚了解到 slashes were a deprecated way that handlebars the library used to navigate objects。我不知道 SendGrid 是否在内部使用了那个确切的 handlebars 库,但我认为这很重要。

我相信绕过键中的斜杠的方法,就像您使用的那样,是用方括号将键括起来。这被称为 literal segments,对您来说看起来像这样:

{{productskumapping.[created/updated]}}