This is my Javascript object that I converted into a string (JSON)
var myObj = {
name: 'John',
age: 25,
group: 'O+'
}
console.log(JSON.stringify(myObj));
I need the output with single quotes (apostrophes) (') and not double quotes ("). Also no quotes or apostrophes on the indexes/keys. I want it to look like this:
{name:'John',age:25,group:'O+'}
I tried this:
var myObj = {
name: 'John',
age: 25,
group: 'O+'
}
console.log(JSON.stringify(myObj).replace(/"([^"]+)":/g, '$1:'));
This removes the quotes on the indexes/keys but the values still have quotes in them. Need to replace them with apostrophes. Tried some more regexes but they did not work.