Earlier quoted context omitted.
Kinda depends on whether you're publishing open source software so that people can use it. And if you're not publishing open source software so that people can use it, why exactly are you doing it? If you don't want people to use it, GPL is the way to go. If you do want people to use it, MIT or BSD is a much better way to go.
GPL is for when you want people to use it. MIT is for when you want megacorporations to turn it into enshittified proprietary software and profit off of it without giving back to you.
Sj.h: A tiny little JSON parsing library in ~150 lines of C99
231–240 of 248 posts
Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#232Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#233What is the purpose of declaring an sj_Reader object with an sj_read method if you don't support lazy parsing? Seems like you could tighten up the code by combining the declaration and parsing into one subroutine.
Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#234Earlier quoted context omitted.
Do you not review libraries you add to your project? A quick scan of the issues page if it's on a forge? Or just reading through the code if it's small enough (or select functions)? Code is the ultimate specification. I don't trust the docs if the behavior is different from what it's saying (or more often fails to mention). And anything that deals with recursive structures (or looping without a clear counter and chec…
If you review libraries, why do you need to quick scan the issues? You would have already identified all the issues right? Right?
Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#235JSON parser libraries in general is a black hole of suffering imo. They're either written with a different use case in mind, or a complex mess of abstractions; often both. It's not a very difficult problem to solve if you only write exactly what you need for your specific use case.
> JSON parser libraries in general is a black hole of suffering imo. Sexprs sitting over here, hoping for some love.
Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#236Earlier quoted context omitted.
> since you'd most likely want to build your own model objects from the JSON, so at some point both of them must be present in memory Not really because the JSON library itself can stream the input. For example if you use `serde_json::from_reader()` it won't load the whole file into memory before parsing it into your objects: https://docs.rs/serde_json/latest/serde_json/fn.from_reader.... But that's kind of academic;…
That's only true if your model objects are serde structs, which is not desirable for a variety of reasons, most importantly because you don't want to tie your models to a particular on-disk format.
In some minority of cases you might not want to do that (e.g. because you need to support multiple versions of a format), but that is rare and can also be handled in various ways directly in Serde.
Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#237Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#238The library doesn’t check for signed integer overflow here: https://github.com/rxi/sj.h/blob/eb725e0858877e86932128836c1... https://github.com/rxi/sj.h/blob/eb725e0858877e86932128836c1... https://github.com/rxi/sj.h/blob/eb725e0858877e86932128836c1... Certain inputs can therefore trigger UB.
-sj_Reader sj_reader(char *data, size_t len) {
+sj_Reader sj_reader(char *data, int len) {
Not everyone needs to waste cycles on supporting JSON files larger than 2^31-1.Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#239Earlier quoted context omitted.
So if its a hobby project designed for just a handful of people, its suddenly okay to endanger them due to being sloppy?
This is an open source project that you're not obligated to use nor did you pay for it. Who is it endangering? The license also makes it clear that the authors aren't liable for any damages.
The license disclaims liability but that doesn't mean the author cannot ever be held liable. Ultimately, who is liable is up to a court to decide.
Re: Sj.h: A tiny little JSON parsing library in ~150 lines of C99
#240Earlier quoted context omitted.
There was a nice article [0] about bloated edge cases libraries (discussion [1]). Sometimes, it's just not the responsibility of the library. Trying to handle every possible errors is a quick way to complexity. [0]: https://43081j.com/2025/09/bloat-of-edge-case-libraries [1]: https://news.ycombinator.com/item?id=45319399
Strongly disagree here because JSON can come from untrusted sources and this has security implications. It's not the same kind of problem that the bloat article discusses where you just have bad contracts on interfaces.