The following code replaces only one single quote:
var a = "[{'column1':'value0','column2':'value1','column3':'value2'}]"; var b = a.replace("'", "\""); console.log(b);
to show double quote you can simple use escape character("\") to show it.
We can use the backslash ( \ ) escape character to prevent JavaScript from interpreting a quote as the end of the string. The syntax of \' will always be a single quote, and the syntax of \" will always be a double quote, without any fear of breaking the string.
replace(/'/g, 'A');
They are the same thing In JavaScript, a string is a sequence of characters enclosed in single or double quotes. The choice of quoting style is up to the programmer, and either style has no special semantics over the other.
var a = "[{'column1':'value0','column2':'value1','column3':'value2'}]"; var b = a.replace(/'/g, '"'); console.log(b);
Edit: Removed \ as there are useless here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With