1
Eklavya
4y

Using JSON instead of a database
Is it a good practice?

Comments
  • 4
    Confused question, I mean you can use pretty much anything to store the data then again pretty much anything for the transit/deserialization.

    Eg. MongoDB uses BSON which is derived from JSON.

    It's perfectly sane to use if the use-case benefits from it.
  • 3
    For config files or other static data, sure. For anything else: NO.
  • 1
    It's written uncompressed and without strict schema. If we go this route, I'd say TOML is more appropriate. At least, it will be a lot readable by human.

    But you'll have to handle all these hot relations on application level (like cascade removal).
  • 1
    Not much different from storing in a Text file, if you're talking about JSON oriented databases, yeah, good for very narrow types of data, but, if you actually want to scale it, it's not a good idea.
  • 1
    Depends entirely on the data.

    A good mix of both is normally a happy balance.
  • 1
    For an MVP or just Proof of concept, yes.

    For real world, no.
    Imagine the file keep growing and growing, your code will have to read it all everytime it opens it. It just doesn't scale and it is prone to errors.
  • 1
    LOL no is the short answer.
    long answer is how much data ?

    json marks every last field with its title, it stores it in text, the bloat is unbelievable compared to a packed binary database !

    for small amounts of data json is fine, but if you're talking a long term solution where the data will pile up then definitely not !
  • 1
    Oo Oo - what if you crash in the middle of updating the file? or multithread updates? Transactions?

    Fuck no. Json is not a R/W database.
  • 1
    Use sqlite
Add Comment