Hacker News new | ask | show | jobs
by dncornholio 1617 days ago
Storing stuff in a json file sounds horrible to me. Why would you want that?
2 comments

Because your data is teeny tiny, not performance critical, and `json.load` and `json.dump` is easy and usually less brittle then you're language's marshalling library.
Why save 10 minutes on setting up a proper database? Data is never teeny tiny, data is never not performance critical :) These decisions only bite you in the ass.
All my side projects have teeny tiny amounts of data. JSON file in the order of KB. Performance is great.

I have one project with a dozen users that handles around 50 reads per second and maybe 30 writes per day, no issues at all. Setting up a DB for that would just bite the next dev in the behind since it would need a lot more maintenance then an apache server with php.

Setting up a database takes way longer than 10 minutes. Data can be teeny tiny. Data can not be performance critical. You literally know nothing about the commenter’s application.
With SQLite, you can have a simple database set up in a minute.
"I just want to serve five kilobytes of data."
PHP supports complex data structures using associative arrays which map to the application requirements. Which can be easily saved in JSON. A SQL database with rows and fields does not always work well with these data structures. Often, as long as the data size is manageable, a json saved in a mediumtext field in MySQL works just fine.