I believe your goal is as follows.
You want to download `strJSON` as a file when a dialog is opened.
In this case, how about the following sample script?
Google Apps Script side:
function openDialog() {
var strJSON = JSON.stringify({"key1": "value1"}); // This is a sample value. Please replace this for your value.
var template = HtmlService.createTemplateFromFile('copy');
template.temp = `data:${MimeType.JSON};base64,${Utilities.base64Encode(strJSON)}`;
var htmlOutput = template.evaluate();
htmlOutput.setWidth(610)
htmlOutput.setHeight(750);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'AttributeRelevance');
}
HTML & Javascript side:
<body></body>
<script>
const filename = "sample.json"; // If you want to change the filename, please modify this.
const a = document.createElement("a");
document.body.appendChild(a);
a.download = filename;
a.href = <?= temp ?>;
a.click();
</script>
I'm not sure about `copy` of your HTML file. So in this answer, I prepared a sample HTML and Javascript.
When the dialog is opened, "strJSON" is converted to the base64 data and it is downloaded as a file.
This sample is from
https://stackoverflow.com/q/69375791/7108653