假设我有一个注释字段,其中包含换行符。 什么解决方案是正确的,它们之间有什么区别?
1
{
"notes" : "test test test \n line2"
}
2
{
"notes" : "test test test \\n line2"
}
谢谢你
在下面的输出中:
{
"notes" : "test test test \n line2"
}
已使用
\n
转义新行字符。
在你的用户界面上,你可能想显示
test test test
line2
我假设您正在从数据存储(可能是 MySQL)检索 json。如果是,请参阅有关在 MYSSQL 中转义换行符的答案和MySQL 字符串文字