Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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();
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: array cut only last 5 element 
Javascript :: regex for a, e, i , o , u 
Javascript :: on focus out javascript 
Javascript :: js settimeout wait element 
Javascript :: create dynamic element in javascript 
Javascript :: declare an array nodejs 
Javascript :: check for string anagram javascript 
Javascript :: new Date().toLocaleDateString day 
Javascript :: javjquery is emptyobject 
Javascript :: jquery grab table row 
Javascript :: if clicked anything 
Javascript :: getserversideprops nextjs 
Javascript :: creating 2d array in javascript 
Javascript :: do some css using js on selector 
Javascript :: regex not something 
Javascript :: onfocus js 
Javascript :: js for 
Javascript :: Scroll elementleft using js 
Javascript :: how to remove sub array null index in javascript 
Javascript :: javascript sum of number in object array 
Javascript :: add two numbers in jquery 
Javascript :: javascript factorial recursion 
Javascript :: get current store id magento 2 
Javascript :: react must be in scope when using jsx 
Javascript :: javascript style inline react 
Javascript :: react-native date time picker 
Javascript :: javascript check if number 
Javascript :: how to print every second in javascript 
Javascript :: how to find the particular key and value in json in javascript 
Javascript :: js cheat sheet 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =