Is it possible to have multi-line strings in JSON?
It\'s mostly for visual comfort so I suppose I can just turn word wrap on in my editor, but I\'m just kinda curious
JSON does not allow real line-breaks. You need to replace all the line breaks with \n
.
eg:
"first line
second line"
can saved with:
"first line\nsecond line"
Note:
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"