The problem of handling the newline character "\ n" in the string

The string returned by the

background contains the newline character "n",

"dfafdafdaf,...."// "" 

I output the content directly to the console and find:

dfafdafdaf,

....

//console.log

then I convert to jsonstring and output to the console:

"dfafdafdaf,\n\n...."//console.log "\n" 

the background asked me to convert the word "characters" to the symbol "characters" (as for why it should be changed to "characters", my colleague said it was a placeholder, and he could convert it to a newline character). Then I transferred it to

as required.
"dfafdafdaf,...."//

after submitting to the backend, it is found to be:

after getting it again.
"dfafdafdaf,...."//

the newline character is missing.

I don"t understand why in the data returned in the background, the n newline character was converted to "break", and I converted to the json string to become"n"? In addition, since there is a problem with the data returned after I directly replace the symbol with the symbol, how should I deal with it?

May.05,2022

because the json encoding itself changes the newline character to "n" two characters

> let s = "hello!\nhi!"
undefined
> console.log(s)
hello!
hi!
undefined
> console.log(JSON.stringify(s))
"hello!\nhi!"
undefined
>
Menu