user1128677 user1128677 - 2 months ago 6
JSON Question

document.write and JSON output

I have some big json configs and want allow users to export them. The problem is JS

cant return a full data, so i decided to use and write. But "write" just "eat" html in json values. This answer helped a lot.

var data = Store.export();
var url = 'data:text/json;charset=utf8,' + encodeURIComponent(data);, '_blank');

But when i try to export really large and long json everything freezes...
How can i modify it to use blank url and unmodified json as text?

My workaround

var myWindow ="", "JSON Settings", '_blank');
myWindow.document.write('<textarea>' + escapeHTML(Store.export()) + '</textarea>');


You could include a multi-line text field in which you would place the data.

This gives it a space to go rather than just being injected into the HTML.

The user would then copy and paste the data out into their own .json file.