<html>
....
<body>
....
<сode id='someId'><!--{JSON OBJECT}--></сode>
</body>
</html>
const comment = document.querySelector('code[id^="someId"]').innerHTML // comment = <!--{JSON OBJECT}-->
<div id="someId">
<!-- COMMENT One-->
<!-- COMMENT Two -->
<!-- {"json": true} -->
</div>
<output></output>
let out = document.querySelector('output');
let el = document.querySelector('#someId');
for (let i = 0; i < el.childNodes.length; i++) {
let child = el.childNodes[i];
if (child.nodeType == 8) {
console.log(child.textContent);
out.innerHTML += ' <br> ' + child.textContent;
}
}