我試圖發送一些Markdown文本到休息api。剛纔我發現在json中不接受斷行。如何發送MarkDown到API
例子。如何將這個發到我的API:
An h1 header
============
Paragraphs are separated by a blank line.
2nd paragraph. *Italic*, **bold**, and `monospace`. Itemized lists
look like:
* this one
* that one
* the other one
Note that --- not considering the asterisk --- the actual text
content starts at 4-columns in.
> Block quotes are
> written like so.
>
> They can span multiple paragraphs,
> if you like.
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all
in chapters 12--14"). Three dots ... will be converted to an ellipsis.
Unicode is supported. ☺
爲
{
"body" : " (the markdown) ",
}
在將其添加到JSON對象之前,您需要「轉義」您的Markdown文本。由於您沒有告訴我們您正在使用哪種語言/框架,因此以下是「 [escape json](http://stackoverflow.com/search?q=escape+json)「。 – Waylan
將Markdown放入字符串或類似字符串的對象中。將該字符串放入適當的數據結構中。使用你的語言的數據到JSON函數。 (提示:** _從來沒有_ **手動構建JSON。) – Chris
謝謝你們,這是一個普遍的問題,但我明白了。謝謝 – 62009030