Is it possible to make a basic CRUD in JSON file?

Asked

Viewed 194 times

1

I have the following scenario.

I have a news site on ASP.NET MVC that currently when accessing it, all information is taken from the bank. I want to take these requests from Front.

I thought I’d make a file Data.json and every time a news was recorded would save in bank and archive upon need.

Ex: Every time the site is open I go to the bank and look for the 5 latest news on Politics and Sports, as I already know how many news from each publishing house I need to present in Frontend, would create only the necessary in the archive.

But as it is not a bank, when you need to "Deactivate" a news for example, you would have to go in the file, remove that news and put another to not break the Frontend scheme.

Is it feasible to do a CRUD to do these operations in the JSON file? Does anyone know a better scheme to get to this point?

  • 1

    You want something like that? https://github.com/typicode/lowdb

  • @gypsy-Morrison-Mendez Exactly this, but I confess that I have no idea how to implement Lowdb with Asp.NET MVC.

  • 1

    I don’t know how to use it either. I’ll have to give you a study to answer.

  • No problem! I’m researching too!!

1 answer

1

Despite the computational cost, an option for this case could be to work directly on serialization and deserialization of class instances that materialize JSON via methods. CRUD work would be in class instances and not in files that could generate an unwanted stream of I/O. It could have a background task to ensure serialization of the data stream in memory to physical file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.