在线 JSON 格式化工具 - 格式化您的 JSON 数据
<p>在线 JSON 格式化工具可以帮助您快速轻松地格式化 JSON 数据,使其更易于阅读和理解。只需将您的 JSON 代码粘贴到下面的输入框中,点击“格式化”按钮即可。该工具会自动将您的 JSON 代码格式化为美观易读的格式。</p>
<textarea id='jsonInput' rows='10' cols='80'></textarea>
<br>
<button onclick='formatJSON()'>格式化</button>
<pre id='formattedJson'></pre>
<script>
// 将JSON格式化并显示在页面上
function formatJSON() {
var input = document.getElementById('jsonInput').value;
try {
var json = JSON.parse(input);
var formattedJson = JSON.stringify(json, null, 4);
document.getElementById('formattedJson').innerHTML = formattedJson;
} catch (error) {
document.getElementById('formattedJson').innerHTML = 'Invalid JSON';
}
}
</script>
原文地址: https://www.cveoy.top/t/topic/RT7 著作权归作者所有。请勿转载和采集!