0

I have a slack payload that would format to markdown. And I'm trying to figure out how to preserve the backtick

var jsonStr = []byte(`{
  "channel": "#edtest",
  "username": "snapshot",
  "attachments": [
        {   
            "mkdwn": true,
            "text": "`this backtick doesn't work`",
        }
    ]
}`)

if you look at the text field, that backtick won't work

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
edmamerto
  • 7,605
  • 11
  • 42
  • 66

1 Answers1

2

You can't escape backticks. When there's long text like this, one thing you can do is to replace them:

var jsonstr=[]byte(strings.Replace(`{
Some json string with ^backticks^
}`,"^","`",-1))

Another option is to add string segments:

var jsonstr=[]byte(`{
Some json string with `+"`backticks`"+`
}`)
Burak Serdar
  • 46,455
  • 3
  • 40
  • 59