udemy-node-notes/playground/json.js

11 lines
304 B
JavaScript
Raw Permalink Normal View History

2017-11-20 23:55:27 +00:00
const fs = require('fs');
var originalNote = {title: 'some title', body: 'some body'}
var originalNoteString = JSON.stringify(originalNote);
fs.writeFileSync('notes.json', originalNoteString);
var noteString = fs.readFileSync('notes.json');
var note = JSON.parse(noteString);
console.log(note.title);