Reading and Writing to a JSON file with Node

preview_player
Показать описание
Seeing what it takes to read JSON data from a file in the filesystem, make changes to the data, and output the resulting JSON data back to a file in the filesystem using Node JS.

I'm just exploring and playing around (don't think I'm an expert at ‘Nodeling’) so feel free to watch as I discover the single spot in my JavaScript file that a semicolon character was truly required, and wait for me to remember that almost everything in JSON needs "double quotes" to work! 🤣 I thought I'd upload all the mistakes too just to be honest, hopefully we both get a laugh out of it.

Also… face reveal 💁‍♂️I think this might be the first time I've shown my face in one of these coding videos!
Рекомендации по теме
Комментарии
Автор

vid is a gem and exactly what I was looking for

juanrios
Автор

I'm probably not the only one that started looking for different node packages for a simple file DB solution, and ended up having problems with packages not supporting commonjs and fiddling around with the Typescript compiler to get compiled esm files unsuccessfully. This video made me motivated to try out working with JSON without having to rely on mysterious external dependencies, thank you!!

leifetter
Автор

Well, this was very, very helpful. Funnily enough, I started to learn Node Js recently because I initially wanted to be able to ammend a json file that I am using to store data in an app I'm working on, but the fs writeFile tutorials had me completely lost; and after while it dawned on me that it might be a good idea to start learning node because I couldn't even get started without having node installed. So here I am; as a rookie, it's interesting seeing your thought process.

TinyMaths
Автор

This was a massive help to me - thank you dude

TyrannicalKev
Автор

Thank you so much, i Love your videos, Keep going <3

manray
Автор

thank you very much, it's very usefull to see you experimenting

aqueuse
Автор

I think you were missing the "./". Like:


const data = require('./data.json');
console.log(data.thing);

rblakewatson
Автор

Amazing video, i think its not necessary to read the file to save JSON on it, you can manage the data by using require('file.json').
Gained a new sub

cienciasdedatosfran
Автор

Hi.. i ask.. how to push json objeck, for example
var json = {
"text":"text1",
"ok" : "text2"
}
How to push the variable json?

lmnlghtt
Автор

Hey man, can you help me out, I want to create a local JSON based db, how do I apply CRUD operations on it, using NodeJS,
this video shows Create and Read, how about update and delete?

abhinav.sharma
Автор

how can you delete a few or one "files" from the data.js

andre
Автор

nice video but keyboard sound is irritating.

amitapatra
Автор

I want use require('fs') in client side server

codeeasy
Автор

please post code to github or something so we can use it...

JOHNSMITH-verq