Answers for "Typescript write JSON to file"

6

js writing to json file

var fs = require('fs');

var data = {}
data.table = []
for (i=0; i <26 ; i++){
   var obj = {
       id: i,
       square: i * i
   }
   data.table.push(obj)
}
fs.writeFile ("input.json", JSON.stringify(data), function(err) {
    if (err) throw err;
    console.log('complete');
    }
);
Posted by: Guest on March-23-2020
0

typescript read json file

"resolveJsonModule": true,
"esModuleInterop": true,
Posted by: Guest on December-18-2020
-2

how to import a json string from a file in typescript

import {default as a} from "a.json";
a.primaryMain
Posted by: Guest on June-16-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language