New line character in JSON

本小妞迷上赌 提交于 2019-12-22 18:27:39

问题


We are using a WCM tool for content entry and content editors will enter content having text and html in the tool. To convert the content into JSON we are using newton JSON as below where we are passing simple dictionary of keys and values:

string output = JsonConvert.SerializeObject(nonJsonResult);

Whenever editor gives content with new lines then we are getting the serailized JSON output with \r\n.

Example input text:

first line

second line

third line

Output:

 {
     "test": "first line\r\nsecond line\r\nthird line"
 }

Is there a way to avoid these characters? If it is inevitable, will these \r\n pose an issue for the other application to which we are sending the JSON response? Are there any more issues like these with newton JSON as I am fairly new to JSON which I need to take care of.

来源:https://stackoverflow.com/questions/41607707/new-line-character-in-json

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!