How do I replace single quotes with double quotes in JavaScript?

后端 未结 7 535
遥遥无期
遥遥无期 2021-02-01 02:10

The following code replaces only one single quote:

7条回答
  •  时光取名叫无心
    2021-02-01 02:39

    Need to use regex for this:

    var a = "[{'column1':'value0','column2':'value1','column3':'value2'}]";
    var b = a.replace(/\'/g, "\"");
    

    http://jsfiddle.net/9b3K3/

提交回复
热议问题