Write HTML string in JSON

前端 未结 11 1424
小蘑菇
小蘑菇 2020-12-09 08:25

Is it possible to write an HTML string inside JSON?

Which I want to write like below in my JSON file:

[
    {
        \"id\": \"services.html\",
             


        
11条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 09:17

    4 Things You Must Do When Putting HTML in JSON:

    1) Escape quotation marks used around HTML attributes like so

    2) Escape the forward slash in HTML end tags.

    Hello World!<\/div>. This is an ancient artifact of an old HTML spec that didn't want HTML parsers to get confused when putting strings in a
    提交回复
热议问题