Multiline string as a value in Json
Multiline string as a value in Json
这个问题已经有了答案:
给定这个Json:
{ "myclass": { "studentname": "myname", "description": "Student has three more credits to complete\n he is taking maths\ n biology this semester " } }
我在jsonlint中会得到一个“description”的Json解析器异常。将“description”更改为接受数组对我不是一个选项。
是否有任何方法在Json中定义多行?
admin 更改状态以发布 2023年5月23日
\n
是唯一的方式。JSON不是编程语言,无法要求其连接字符串。这也取决于上下文。
这个会起作用
{ "myclass": { "studentname": "myname", "description": "Student has three more credits to complete\nhe is taking maths\nbiology this semester" } }
这个不起作用
{ "myclass": { "studentname": "myname", "description": "Student has three more credits to complete\n he is taking maths\n biology this semester" } }