【问题标题】:Unable to get a value from the key in Sendgrid template无法从 Sendgrid 模板中的键获取值
【发布时间】:2021-09-23 07:19:53
【问题描述】:

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

“productskumap”:{ “创建/更新”:2, “失败”:0 }

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

【问题讨论】:

    标签: sendgrid sendgrid-api-v3 sendgrid-templates


    【解决方案1】:

    这里是 Twilio SendGrid 开发人员宣传员。

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

    我相信绕过键中的斜线的方法,就像你有的那样,是用方括号包围键。这被称为literal segments,对你来说看起来像这样:

    {{productskumapping.[created/updated]}}
    

    【讨论】:

    • 谢谢你的工作!!。你刚刚把我从复杂的 json 转换中救了出来。
    • 太棒了!您能否将答案标记为正确,以便遇到此问题的其他人可以看到它的帮助?
    猜你喜欢
    • 2015-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-16
    • 2019-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多