【问题标题】:Adding a line break in json在json中添加换行符
【发布时间】:2020-03-31 13:29:46
【问题描述】:

谁能告诉我如何在创建 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"
    }
  }
}

【问题讨论】:

  • 我需要在“客户详细信息:”之后换行

标签: json liquid zendesk


【解决方案1】:

试试这个

{
   "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`
      }
   }
}

【讨论】:

    【解决方案2】:

    在需要换行的地方使用\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"
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 2018-11-26
      • 1970-01-01
      相关资源
      最近更新 更多