Difference between revisions of "Writing JSON object to a file in Node.js"

From Logic Wiki
Jump to: navigation, search
(Created page with "Category:Json Category:Node.js If output is a string, then specify the encoding. and remember the flag options as well.: <pre class="brush:javascript";> const fs = r...")
 
(→‎JSON Hosting)
 
(2 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
If output is a string, then specify the encoding. and remember the flag options as well.:
 
If output is a string, then specify the encoding. and remember the flag options as well.:
  
−
<pre class="brush:javascript";>
+
<pre class="brush:javascript;">
 
const fs = require('fs');
 
const fs = require('fs');
 
const content = JSON.stringify(output);
 
const content = JSON.stringify(output);
Line 16: Line 16:
 
});  
 
});  
 
</pre>
 
</pre>
 +
 +
 +
== JSON Hosting ==
 +
 +
[https://www.evennode.com https://www.evennode.com] 6 Eur / month
 +
 +
[https://www.openshift.com/ https://www.openshift.com/pricing/index.html] Free for 1 project or  50 USD / month for 10 projects
 +
 +
[https://www.digitalocean.com https://www.digitalocean.com] starting from 5 usd / month

Latest revision as of 07:55, 9 April 2018


If output is a string, then specify the encoding. and remember the flag options as well.:

const fs = require('fs');
const content = JSON.stringify(output);

fs.writeFile("/tmp/phraseFreqs.json", content, 'utf8', function (err) {
    if (err) {
        return console.log(err);
    }

    console.log("The file was saved!");
}); 


JSON Hosting

https://www.evennode.com 6 Eur / month

https://www.openshift.com/pricing/index.html Free for 1 project or 50 USD / month for 10 projects

https://www.digitalocean.com starting from 5 usd / month