FakeDetect / json_viewer.js
Basti1110's picture
Upload 6 files
6f9ff59 verified
raw
history blame contribute delete
468 Bytes
function formatJSON() {
const pre = document.querySelector('pre');
try {
const rawText = pre.textContent;
const jsonStart = rawText.indexOf('{');
const jsonEnd = rawText.lastIndexOf('}');
const jsonText = rawText.slice(jsonStart, jsonEnd + 1);
const obj = JSON.parse(jsonText);
pre.innerHTML = '<code>' + JSON.stringify(obj, null, 2) + '</code>';
} catch (e) {
console.error("Invalid JSON output");
}
}
window.onload = formatJSON;