Flexible Zero-Footprint JSON Parser in C
C Makefile
Failed to load latest commit information.
man full sweep to clean the repo slate for v2 work Oct 5, 2014
src add dual MIT license, closes #16 Sep 28, 2016
test Add consts to public function signature Jul 10, 2015
.gitignore man page for js0n and example program Aug 2, 2014
.travis.yml both travis compilers too Oct 6, 2014
LICENSE.txt add dual MIT license, closes #16 Sep 28, 2016
README.md add dual MIT license, closes #16 Sep 28, 2016
UNLICENSE use the unlicense.org text to make the public domain clear Oct 7, 2014


js0n - Flexible Zero-Footprint JSON Parser in C

A one-pass minimal overhead walk of the raw bytes, using each one as an index into a jump table to determine state transitions.

  • public domain or MIT license, single js0n.c file with one function
  • easy to use, just returns a given key-value pair location in the JSON string
  • no dependencies, embedded friendly
  • requires no memory/malloc or copying, uses only what is passed in (up to int max length)
  • more flexible than strict JSON and allows bare keys (non-validating)
  • optimized for high speed scanning/routing of small chunks of json, stops parsing upon match
  • safely errors on anything really bad (binary, NULLs, etc)

Parsing this:

    "barbar": [
    "foo": "bar",
    "obj": {
        "a": "b"

Using val = js0n("barbar", 6, json, strlen(json), &vlen) would return a val pointing to [1,2,3] and set vlen to 7.

For arrays, pass NULL as the key, and the array offset as the second argument.

When the value is not found NULL is returned, if there were any parsing errors then vlen will be set to -1.

To determine if the returned value is an actual JSON string or a bare value (like "true" vs true), simply check if it starts with a quote character via if(val && *(val-1) == '"').

For more usage examples see the test.json and test.c.


See v1.0 for the original js0n function that returned an index of offsets for all key/values in one pass.