有没有办法添加Html <pre> into JSON file

时间:2017-06-19 13:52:21

标签: json

Below JSON file, I would like to create line break by putting the content into JSON using "pre", Is this possible,

 {
  "Name": "<pre>Hello, How are You?
            I am Good<pre>",
  "Age":  12
}

1 个答案:

答案 0 :(得分:0)

The specification of JSON doesn't support multiline texts.

But you can use use the \r and the \n character to create a line break in the text.

{
    "Name": "<pre>Hello, How are You?\r\nI am Good<pre>",
    "Age":  12
}

Be aware of that the line break character is different on unix platforms.

A string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms.