Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
I think writing a JSON parser should be perfectly fine, it's quite a simple (while imperfect) format. I would say 50 lines of header + 500 lines of .cpp file should be plenty to write a solid implementation, should be doable in an afternoon.
But if you disagree, you should try this: https://github.com/nlohmann/json
Last I checked, a git clone download 260 Megabytes of data. The project consists of many many files, but most notably it is a C++ header-only library consisting of 24000 lines of header file to be included into every (transitively) dependent .cpp file.
Just #include it and add a simple main() { printf("Hello, world\n"); }, this will take about 1 sec to compile on my laptop.
Add a tiny amount of code to "parse" the JSON string "3" (which I think is not valid JSON actually. But anyway) and compile + link. Takes 2 secs on my laptop. With -O2, I'm at 3.5 seconds.
Imagine writing a larger project with many many .cpp file that include a header file that publishes such a dependency.
Related posts
- Show HN: Jsonpak: JSON that is not bloated for Nim
- JSON for Modern C++ 3.11.3 (first release since 473 days)
- It is either a clever technique or a sad failure
- How to compile project to separate files to prevent having single large executable as a result?
- C++ that allows tracking peer to peer multimedia streaming connections using a Flat File - NOT MySql