mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
575a29c424
commit
518fc63224
1 changed files with 3 additions and 0 deletions
|
|
@ -53,6 +53,9 @@
|
||||||
document.querySelector('#json-format').addEventListener('click', (ev) => {
|
document.querySelector('#json-format').addEventListener('click', (ev) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
let json = document.querySelector('textarea[name="json"]').value.trim();
|
let json = document.querySelector('textarea[name="json"]').value.trim();
|
||||||
|
if (!json) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(json);
|
const parsed = JSON.parse(json);
|
||||||
document.querySelector('textarea[name="json"]').value = JSON.stringify(parsed, null, 2);
|
document.querySelector('textarea[name="json"]').value = JSON.stringify(parsed, null, 2);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue