问题
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