我有一個(gè)可以格式化為 markdown 的松弛有效負(fù)載。我正在嘗試找出如何保留反引號(hào)var jsonStr = []byte(`{ "channel": "#edtest", "username": "snapshot", "attachments": [ { "mkdwn": true, "text": "`this backtick doesn't work`", } ]}`)如果你查看文本字段,反引號(hào)將不起作用
1 回答

繁星淼淼
TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個(gè)贊
你無(wú)法逃避反引號(hào)。當(dāng)出現(xiàn)這樣的長(zhǎng)文本時(shí),您可以做的一件事就是替換它們:
var jsonstr=[]byte(strings.Replace(`{
Some json string with ^backticks^
}`,"^","`",-1))
另一種選擇是添加字符串段:
var jsonstr=[]byte(`{
Some json string with `+"`backticks`"+`
}`)
- 1 回答
- 0 關(guān)注
- 110 瀏覽
添加回答
舉報(bào)
0/150
提交
取消