How to escape special characters in building a JSON string?

后端 未结 11 1032
北恋
北恋 2020-11-22 04:18

Here is my string

{
    \'user\': {
        \'name\': \'abc\',
        \'fx\': {
            \'message\': {
                \'color\': \'red\'
            }         


        
11条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 04:40

    Using template literals...

    var json = `{"1440167924916":{"id":1440167924916,"type":"text","content":"It's a test!"}}`;
    

提交回复
热议问题