Note that your json
variable should contain a string with backslash escaped quotes when passing it to the template.
Other solution would be to first render your template
var textarea = template.render();
and then add the content afterwards via
textarea.value = json;
Of course you'll then need to remove the json
from your template.