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

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

The following code replaces only one single quote:

7条回答
  •  醉话见心
    2021-02-01 02:55

    This looks suspiciously like bad JSON, so I suggest using actual array and object literals, then encoding the proper way:

    var a = [{'column1':'value0','column2':'value1','column3':'value2'}];
    var b = JSON.stringify(a);
    

提交回复
热议问题