Is it correct to use JSON to store data that does not need to be in a database?

0

Ex: In the company where I work put a lot of data in my code that does not need to be in the database, but it is not actually text or content. They are a lot of validations and depending on the clause it returns a certain type of content, the problem is that everything is in the same file, which is very difficult to read code, usually in these cases I like to leave the data in a JSON file and just take what's necessary leaving the source code leaner.

Is this practice correct? What would be best?

    
asked by anonymous 24.09.2015 / 17:25

2 answers

2

It's hard to say without seeing the concrete case. There is nothing wrong in the abstract. Even today all modern application configuration files use this format. Previously used the famous format ini , or XML, or even proprietary formats.

It should not be your case but there are already a lot of people exchanging data in JSON format.

You should find out why it is difficult to read and if there is anything that can be done to change it. But I doubt the problem is JSON.

Particularly I prefer more structured ways of storing certain information when possible, so I'd rather leave it in memory in a array or other suitable data structure or even tables in the database. >

Even though this is in the code and is already in memory, I would throw the data into a data structure and avoid JSON's string access at all times.

  

If you give more details I improve the answer.

    
24.09.2015 / 17:34
0

Power can, I believe there are no right or wrong practices, depends a lot on what you need.

But the question is whether you will need to consult this at all times of the file. Reading the file at all times can cause unnecessary slowness.

The interesting thing is to do as colleague Sérgio quoted in the comment. Import this data into memory (leaving it in the session for web or static in the application).

So reading will not be slow, especially if you need it all the time.

    
24.09.2015 / 17:32