在 Automation for JIRA 中转义 webhook 的 JSON 负载中的值

Escape values in webhook's JSON payload in Automation for JIRA

我使用 Code Barrel 的 Automation for JIRA 插件配置了一个 webhook 操作。它向需要 JSON 负载的端点发送请求。

使用模板语法,我可以编写一个像

这样的自定义正文
{"some_key": "{{issue.summary}}"}

将模板值放入 JSON 负载中:

然而,这是脆弱的;如果任何模板值包含双引号或反斜杠,我们可能会生成语法无效的 JSON 有效负载。

Automation for JIRA 中是否有任何方法可以转义包含在 JSON 字符串中的文本?

我刚刚做了一个快速发布,使您能够对这些值进行编码。您可以在 - https://docs.codebarrel.io/automation/smart-fields/working-with-strings.html#encoding

找到文档

虽然很简单:

{"some_key": "{{issue.summary.jsonEncode}}"}

这是在云中运行的,在服务器版本 3.9.7 中可用。

希望这就是您所追求的。