Are multi-line strings allowed in JSON?

JSON does not allow real line-breaks. You need to replace all the line breaks with \n.


"first line
second line"

can saved with:

"first line\nsecond line"


for Python, this should be written as:

"first line\\nsecond line"

where \\ is for escaping the backslash, otherwise python will treat \n as
the control character “new line”

Leave a Comment