Skip to content

ohler55/ojc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

{}j Build Status

Optimized JSON in C

Description

Optimized JSON in C (OjC), as the name implies, was written to provide optimized JSON handling. It is derived from the underlying C parser in Oj and more recently OjG. The intended use is for applications that need the maximum performance when reading large JSON document from a file or socket.

Besides being a true streaming parser OjC produces a structure that handles all JSON constructs. It does not use a Hash or Map to represent the JSON object type but keeps all occurances of a pairs in the object element.

Multiple JSON elements are allowed in a single stream or from a socket. A callback mechanism is provided to return full JSON elements for each entry in a JSON stream.

Simple JSON Parsing Example

#include <stdio.h>
#include "oj/oj.h"

int
main(int argc, char **argv) {
    const char      *str ="{\"num\": 12.34e567}"
    struct _ojErr   err = OJ_ERR_INIT;
    ojVal           val;

    if (NULL == (val = oj_parse_str(&err, str, NULL))) {
        printf("Parse error: %s at %d:%d\n", err.msg, err.line, err.col);
    } else {
        oj_destroy(val);
    }
    oj_cleanup();
    return err.code;
}

More example can be be found in the examples directory.

Benchmarks and Comparisons

A comparison of OjC and simdjson is in the compare directory with results in the results.md file. For a more entertaining comparison take a look at OjC and Simdjson racing.

Documentation

Documentation: http://www.ohler.com/ojc

Source

GitHub repo: https://github.com/ohler55/ojc

Releases

See CHANGELOG