Full Simplified JSON support in json.h

In a previous post (Partial) Simplified JSON support in json.h I covered the partially added simplified JSON support I had added to json.h. One of the things I covered was my unwillingness to implement two of the features of simplified JSON, commas being optional and replacing : with =. I argued that both of these were unnecessary and stupid additions to the library. I was wrong. The immediate feedback I received detailed good reasons why these were useful, but more importantly - why did I half-arse implementing a feature that was requested by a user!

Introducing utest.h!

So as you may (or may not) already know - I’ve written two tiny C libraries - utf8.h and json.h. One of the questions that most plagued me when writing these libraries was ‘How should I write the tests for them?’ I could put them in a separate repository, I could put them within the repository, should I create a new testing framework every time? It would be useful to be able to have test cases spread across multiple files… and the thoughts went on and on.

(Partial) Simplified JSON support in json.h

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.

json.h performance (update!)

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.

json.h performance (vs other C/C++ JSON parsers)

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;