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

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