4
I want to make a website to test some things. The site is running on my home server done with Wamp. I was told that I could make a small database using JSON files. I have a JSON file in the website folder that contains the following:
[
{
"titulo":"Filme A",
"titulo original":"Movie A",
"duracao":"120 min",
"genero":"Genero 1",
"Atores":"Nome 1, Nome 2",
"Rate":"1",
"Visto":"sim"
},
{
"titulo":"Filme B",
"titulo original":"Movie B",
"duracao":"160 min",
"genero":"Genero 2",
"Atores":"Nome 1, Nome 2",
"Rate":"2",
"Visto":"sim"
},
{
"titulo":"Filme C",
"titulo original":"Movie C",
"duracao":"140 min",
"genero":"Genero 3",
"Atores":"Nome 1, Nome 2",
"Rate":"",
"Visto":"nao"
}
]
With your help I was able to list the properties of these objects from the JSON array.
Now I’m trying to save a new object inside this JSON array through information that the user puts when the questions are asked and for that I need a scripting on the server side, I chose Node.js because I’m a little more familiar with Javascript. I have little knowledge and almost none of Node.js. But I would still like any help from you to try to learn something. I have read on the internet about Node.js and JSON but still don’t understand how to save JSON on the server using Node. Any explanation will be very helpful.
See on Jsfiddle
I didn’t quite understand what the Filesystem API would be. Enter the code you showed first inserts "Hey there!" in the base date, but what base date is this? It’s some JSON file?
– Pedro Gelli
In fact he is only writing in the file the phrase "Hey There!" in a physical file and not in bank.
– IgorCarvalho