Choose Your Standard
Choose one of three JSON standards:
- RFC 4627 - The original JSON standard, “discovered” by Douglas Crockford.
- RFC 8259 - The latest JSON standard.
- JSON5 - An unofficial JSON standard that incorporates features from ECMAScript 5.1 (ES5).
Extension Support
Judo optionally supports comments and trailing commas for RFC 4627 and 8259 parsers. When both extensions are enabled, Judo becomes a JSONC parser. These features are already incorporated into JSON5.
MISRA C:2012 Compliant
The Judo scanner honors all Mandatory, Required, and Advisory rules defined by MISRA C:2012 and its amendments, including Rule 17.2, which requires functions to be non-recursive. As a result, Judo does not implement a recursive scanner or parser.
The Judo parser honors all MISRA rules with the exception of Advisory Rule 11.5. If absolute conformance is required, then the parser can be disabled at configuration time.
The complete MISRA compliance table with deviations is documented here.
Robust and Trustworthy
Judo is thread-safe and does not rely on the C standard memory allocators. It can detect malformed UTF-8 and problematic conditions not fully specified by the JSON specification, like mismatched UTF-16 surrogate pairs.
Lightweight Design
Judo’s scanner consists of only three functions, all of which are idempotent. The scanner incrementally returns tokens on demand for you to process as you see fit.
Judo’s parser is optional. It builds an in-memory tree structure with a custom memory allocator you provide. Both the scanner and parser can process null and non-null terminated JSON strings.
Ultra Portable
Judo does not require an FPU or 64-bit integers. It is written in C99 and only requires a few features from libc which are listed in the following table.
Header | Types | Macros | Functions |
---|---|---|---|
stdint.h | uint8_t , uint16_t ,int32_t , uint32_t |
||
stdbool.h | bool , true , false |
||
stddef.h | size_t , NULL |
||
string.h | memcpy , memset , memcmp |
||
assert.h | assert |
||
math.h | INFINITY [1], NAN [1] |
[1] Only required when floating-point numbers are enabled.
Extensively Tested
Judo is tested in the following ways:
- Unit tests with 100% branch coverage
- Fuzz tests
- Out-of-memory tests
- Static analysis
- Valgrind analysis
- Code sanitizers (UBSAN, ASAN, and MSAN)
- Extensive use of assert() and run-time checks
Out-of-Memory Tests
All out-of-memory conditions are tested by running each test case in a loop, counting upwards from zero, with a custom allocator that fails on the Nth allocation. The test passes when the implementation no longer returns an out-of-memory error, meaning all out-of-memory paths have been tested. Code coverage is used to verify all branches are taken.
Feature Combination Testing
Judo is highly configurable. To verify correctness, the test suite explores combinations of extensions (e.g. comments, trailing commas), each floating point storage type, and each supported JSON standard.