Parsing string as JSON with single quotes?

后端 未结 7 901
走了就别回头了
走了就别回头了 2020-11-22 10:22

I have a string

str = \"{\'a\':1}\";
JSON.parse(str);
VM514:1 Uncaught SyntaxError: Unexpected token \'(…)

How can I parse the above stri

7条回答
  •  隐瞒了意图╮
    2020-11-22 10:46

    I know it's an old post, but you can use JSON5 for this purpose.

    
    
    

提交回复
热议问题