I\'m thinking about embedding arbitrary JSON in the DOM like this:
See Rule #3.1 in OWASP's XSS prevention cheat sheet.
Say you want to include this JSON in HTML:
{
"html": ""
}
Create a hidden Now you can access it by reading the
textContent of the element using JavaScript and parsing it:var text = document.querySelector('#init_data').textContent;
var json = JSON.parse(text);
console.log(json); // {html: ""}