JSFiddle - React, Tailwind, and code Playground
HTML
<a id="exportJSON" onclick="exportJson(this);" class="btn"><i class="icon-download"></i> export json</a>
JavaScript
function exportJson(el) {
var obj = {
a: 123,
b: "4 5 6"
};
var data = "text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(obj));
// what to return in order to show download window?
el.setAttribute("href", "data:"+data);
el.setAttribute("download", "data.json");
}