Answers for "export data in json format in javascript"

0

export data in json format in javascript

"use strict";

function exportToJsonFile(jsonData) {
    let dataStr = JSON.stringify(jsonData);
    let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);

    let exportFileDefaultName = 'data.json';

    let linkElement = document.createElement('a');
    linkElement.setAttribute('href', dataUri);
    linkElement.setAttribute('download', exportFileDefaultName);
    linkElement.click();
}
Posted by: Guest on June-30-2021

Code answers related to "export data in json format in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language