DEV Community

massiva2
massiva2

Posted on

Is it possible to write a JSON file from a vue program?

I would like to know and what is possible to write JSON file which is in the same machine as my application using a vue program. To read a file I imported the json and it works well, on the other hand to write or modify I did not find how to do it.
My goal is to use the JSON as a database.

Top comments (4)

Collapse
 
terabytetiger profile image
Tyler V. (he/him)

This StackOverflow question should help with the creation of a JSON file:

24

Some while ago I started learning Vue.js and a short while after, I started a bigger project, not keeping in mind, that Javascript has limited options to interact with the local file system I set up the project via vue-cli, so I have to start the website via npm startโ€ฆ

However using a local file as a database is a little less clear of an answer depending on what you're trying to accomplish. If the user is creating their own local database for while they use the app, this would work (as long as the user only uses the app from that device).

But for a database that connects to other users you might want to look into Supabase or Firebase or CouchDb combined with PouchDb if you're interested in hosting the Database yourself :)

Collapse
 
massiva2 profile image
massiva2

Hello, thank you for your answer. But in the proposals it gives it does not write to a file. I have a file and I need to inject my data from the program to my file
Yes the database I will use it only when the program is running

Collapse
 
terabytetiger profile image
Tyler V. (he/him)

The Blob and Electron fs methods both will create a file - it's just a matter of saving the file to the location where your app is expecting it to be ๐Ÿ™‚

Collapse
 
massiva2 profile image
massiva2

Hello, thank you for your answer. But in the proposals it gives it does not write to a file. I have a file and I need to inject my data from the program to my file
Yes the database I will use it only when the program is running