'use strict';
const invalidJSON = `{"root": {'html': '<div class="header1"></div>', 'fragment': '<div class="footer"></div>'}}`;
let validJSON = invalidJSON.replace(/'/g, '"');
validJSON = validJSON.replace(/="+[A-z0-9]*"/g, (str) => {
return str.replace(/"/g, '\\"');
});
console.log(validJSON);
// => {"root": {"html": "<div class=\"header1\"></div>", "fragment": "<div class=\"footer\"></div>"}}