showing results for - "export data in json format in javascript"
Domenico
17 May 2020
1"use strict";
2
3function exportToJsonFile(jsonData) {
4    let dataStr = JSON.stringify(jsonData);
5    let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
6
7    let exportFileDefaultName = 'data.json';
8
9    let linkElement = document.createElement('a');
10    linkElement.setAttribute('href', dataUri);
11    linkElement.setAttribute('download', exportFileDefaultName);
12    linkElement.click();
13}