Skip to content

default-writer/c-json-parser

Repository files navigation

C JSON parser

  • lightning-fast implementation of a JSON parser
  • c89 compatible
  • easy to read, learn and implement
  • performance improvement rate of x4/x4 for speed/memory compared to json-c
  • just a little bit slower (x0.5) than simdjson

badges

CodeQL

Speed comparison

Metric simdjson c-json-parser(*) c-json-parser json-c
execution time (100K run) 00:00:00.395 00:00:00.881 00:00:01.182 00:00:04.093
execution time (1M runs) - 00:00:08.808 00:00:11.838 00:00:42.702
allocation calls (100K runs) - 0 20,000,000 52,900,000
allocation calls (1M runs) - 0 200,000,000 529,000,000
total heap usage (100K runs) - 0 806,400,000 4,179,600,000
total heap usage (1M runs) - 0 8,064,000,000 41,796,000,000

(*) - alloc-free version (fixed buffer size)

docs

screenshots

logo_c_json_parser

tools

Ninja + Clang

prerequisites

Debian/Linux

sudo apt install -y clang lld

json-c

mkdir build
cd build
git clone https://github.com/json-c/json-c.git
cd json-c
cmake -DCMAKE_INSTALL_PREFIX=../../libs/ -DCMAKE_BUILD_TYPE=release
make all install

or just run (linux-based)

./bin/install_json_c.sh

building

./build.sh
./build-json-c.sh

or

ninja -f build.linux.ninja && ./test-main

testing

ninja -f build.linux.ninja -t clean > /dev/null 2>&1 && ninja -f build.linux.ninja && ninja -f build.linux.ninja -t clean > /dev/null 2>&1

profiling / performance tests (json-c)

ninja -f build.linux.ninja -t clean > /dev/null 2>&1 && ninja -f build.linux.ninja perf && ninja -f build.linux.ninja -t clean > /dev/null 2>&1
ninja -f build.linux.ninja -t clean > /dev/null 2>&1 && ninja -f build.linux.ninja perf-json-c && ninja -f build.linux.ninja -t clean > /dev/null 2>&1

python

python3 test/perf_test.py

About

Simple json parser

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages