首页 > 解决方案 > 在json中添加换行符

问题描述

谁能让我知道如何在创建 json 时添加换行符。我正在尝试使用 api 在 zendesk 中使用评论更新票证。但是,问题是它需要格式化如下:

最后一封跟进电子邮件已发送给客户票 {{ticket.id}}。请致电客户并在票据上添加备注。
客户详细信息:
姓名:{{ticket.requester.name}}
电话:{{ticket.requester.phone}}

谢谢

下面是我要发送的 Json。如果我添加一个简单的输入,那么我会收到错误。我相信对于使用过液体的人来说会很容易。

{
  "ticket": {
    "comment": {
      "public": false,
      "body": "The last follow up email has been sent to the customer for the ticket {{ticket.id}}. Please call the customer and add a note to the ticket. Customer details:Name: {{ticket.requester.name}}, Phone: {{ticket.requester.phone}} Thank you"
    }
  }
}

标签: jsonliquidzendesk

解决方案


\n在需要换行的地方使用,例如

{
  "ticket": {
    "comment": {
      "public": false,
      "body": "The last follow up email has been sent to the customer for the ticket {{ticket.id}}. Please call the customer and add a note to the ticket.\nCustomer details:\nName: {{ticket.requester.name}},\nPhone: {{ticket.requester.phone}}\n\nThank you"
    }
  }
}

推荐阅读