Trying to replace a single backslash \
with two \\
, but encountering issues with double quotes.
var json = {
"DateToday": "2021-08-11",
"MetaData": [
{
"id": "222",
"nameUsed": " \"data\" somemorefillerdata» - somemorefillerdata «somemorefillerdata»",
"type": "movies"
}
]
}
let newJson = JSON.stringify(json)
let newnewJson = newJson.replace(/\\"/g, "\\\\");
let newnewnewJson = JSON.parse(newnewJson)
console.log(newnewnewJson)
Although it kind of works, the output is missing the quotes as shown below:
{
DateToday: '2021-08-11',
MetaData: [
{
id: '222',
nameUsed: ' \\data\\ somemorefillerdata» - somemorefillerdata «somemorefillerdata»',
type: 'movies'
}
]
}