With the help of the rather awesome @ocornut - I’ve managed to get a variant of simplified JSON support into json.h!
So first off - what is simplified JSON? Taken straight from the Bitsquid blog;
Assume an object definition at the root level (no need to surround entire file with { }) Commas are optional Quotes around object keys are optional if the keys are valid identifiers Replace : with = Of the four points above, I’m going to argue that only 1.
So previously I tested my json.h library’s performance against other JSON libraries in the wild (json.h performance (vs other C/C++ JSON parsers). My JSON parser wasn’t performing as I’d expect in the tests, so I’ve spent a good amount of time looking at why.
Before we begin, you can find the sources to my public domain, one .c/one .h file json.h library here - https://github.com/sheredom/json.h
A little information on my initial approach.
One of the first questions I had when I open sourced my json.h library was how fast it can parse compared to other commonly used JSON libraries around. I’ve gone through all of the JSON libraries in C/C++ that I find tolerable (and I’ll document which ones I wouldn’t touch with a barge pole and why too!) and performed a performance comparison on them.
First off, I tested the following JSON C/C++ libraries;
Back in May, the rather awesome imgui creator @ocornut asked the following;
And it got me thinking - why isn’t there a simple JSON reader/writer lib in the same vein as the stb_* libraries that performs a single call to malloc to encode the state? I couldn’t find one, so I decided to write my own.
I’m introducing json.h - my one header/one source json library that will parse a JSON source into a single allocation buffer, and also has functions to write out the minified version of the JSON, and a pretty print function (for human readable JSON).
Since my last post introducing utf8.h I’ve been frantically working on fleshing out the core utf8* functions to match the str* ones, and also listening to developer feedback!
Firstly, you can check out the one header C/C++ library here - utf8.h.
@daniel_collin suggested adding an ASCII only utf8casecmp, which has been added. I’m looking into extending this to support more of the characters in Unicode (the most obvious ones that I can understand are ASCII characters with accents).