我正在编写一个可由 Java 程序读取的 JSON 文件。片段如下...
{
"testCases" :
{
"case.1" :
{
"scenario" : "this the case 1.",
"result" : "this is a very long line which is not easily readble.
so i would like to write it in multiple lines.
but, i do NOT require any new lines in the output.
I need to split the string value in this input file only.
such that I don't require to slide the horizontal scroll again and again while verifying the correctness of the statements.
the prev line, I have shown, without splitting just to give a feel of my problem"
}
}
}
Per 规格 http://json.org/, JSON 语法的char产量可以采用以下值:
- 任何 Unicode 字符-除外-
"
-or-\
-或控制字符
\"
\\
\/
\b
\f
\n
\r
\t
-
\u
四位十六进制数字
换行符是“控制字符”,所以不,你可以not字符串中有一个换行符。但是,您可以使用任意组合对其进行编码\n
and \r
你需要。
The JSONLint http://jsonlint.com工具确认您的 JSON 无效。
而且,如果您想在 JSON 语法中编写换行符而不实际在数据中包含换行符,那么您就更加不走运了。虽然 JSON 的目的是在一定程度上对人类友好,但它仍然是data并且您尝试对该数据应用任意格式。这绝对不是 JSON 的意义所在。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)