Home > database >  How to convert JSON object to file and then response it using ExpressJS
How to convert JSON object to file and then response it using ExpressJS

Time:12-05

I have an pretty large JSON object (~500MB) and i want to convert it to file before send it to user. What is the best way to achieve this using ExpressJS, any suggestion would be grateful.

CodePudding user response:

1- Convert json to string

 var json = JSON.stringify(obj);

2- Use fs to write json on file

 var fs = require('fs');
 fs.writeFile('fileName.json', json, 'utf8', callback);
  • Related