Update write-json-to-file.md

This commit is contained in:
Angelos Chalaris
2017-12-15 13:15:51 +02:00
committed by GitHub
parent 4d3a9bbcee
commit e34229c51f

View File

@ -5,5 +5,5 @@ Use `fs.writeFile()`, template literals and `JSON.stringify()` to write a `json`
```js
const fs = require('fs');
const jsonToFile = (obj, filename) => fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2))
// jsonToFile({test: "is passed"}, 'testJsonFile')
// jsonToFile({test: "is passed"}, 'testJsonFile') -> writes the object to 'testJsonFile.json'
```