How to escape special characters in building a JSON string?

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

Here is my string

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


        
11条回答
  •  不要未来只要你来
    2020-11-22 04:36

    May be i am too late to the party but this will parse/escape single quote (don't want to get into a battle on parse vs escape)..

    JSON.parse("\"'\"")
    

提交回复
热议问题