Skip to content

Commit

Permalink
Fix broken JSON files
Browse files Browse the repository at this point in the history
The downloaded files lost all quotation marks causing rebuilt PSBs not to function.
  • Loading branch information
Shaggythecat authored Jan 14, 2024
1 parent 0b0facf commit a1a6870
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,25 @@
}

function saveUpdatedJson() {
// Convert the updated JSON object to a string
var updatedJsonString = JSON5.stringify(jsonData, null, 2);
// Get the original filename
var originalFilename = document.getElementById('jsonUpload').files[0]?.name || 'updated_data.json';

// Convert the updated JSON object to a string with quotes for all keys
var updatedJsonString = JSON.stringify(jsonData, (key, value) => {
// Exclude quotes for numeric values of specific keys
if (["height", "left", "originX", "originY", "top", "width"].includes(key)) {
return Number(value);
}
return value;
}, 2);

// Create a Blob containing the updated JSON data
var blob = new Blob([updatedJsonString], { type: 'application/json' });

// Create a download link and trigger the download
var link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'updated_data.json';
link.download = originalFilename;
link.click();
}

Expand Down

0 comments on commit a1a6870

Please sign in to comment.