https://github.com/json-c/json-c is the official code repository for json-c. See the wiki for release tarballs for download. API docs at http://json-c.github.io/json-c/

Related tags

JSON c json hacktoberfest
Overview

\mainpage

json-c

  1. Overview and Build Status
  2. Building on Unix
  3. CMake options
  4. Testing
  5. Building with vcpkg
  6. Linking to libjson-c
  7. Using json-c

JSON-C - A JSON implementation in C

Build Status

Test Status

JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects. It aims to conform to RFC 7159.

Building on Unix with git, gcc and cmake

Home page for json-c: https://github.com/json-c/json-c/wiki

Prerequisites:

  • gcc, clang, or another C compiler

  • cmake>=2.8, >=3.16 recommended

To generate docs you'll also need:

  • doxygen>=1.8.13

If you are on a relatively modern system, you'll likely be able to install the prerequisites using your OS's packaging system.

Install using apt (e.g. Ubuntu 16.04.2 LTS)

sudo apt install git
sudo apt install cmake
sudo apt install doxygen  # optional
sudo apt install valgrind # optional

Build instructions:

json-c GitHub repo: https://github.com/json-c/json-c

$ git clone https://github.com/json-c/json-c.git
$ mkdir json-c-build
$ cd json-c-build
$ cmake ../json-c   # See CMake section below for custom arguments

Note: it's also possible to put your build directory inside the json-c source directory, or even not use a separate build directory at all, but certain things might not work quite right (notably, make distcheck)

Then:

$ make
$ make test
$ make USE_VALGRIND=0 test   # optionally skip using valgrind
$ make install

Generating documentation with Doxygen:

The library documentation can be generated directly from the source code using Doxygen tool:

# in build directory
make doc
google-chrome doc/html/index.html

CMake Options

The json-c library is built with CMake, which can take a few options.

Variable Type Description
CMAKE_INSTALL_PREFIX String The install location.
CMAKE_BUILD_TYPE String Defaults to "debug".
BUILD_SHARED_LIBS Bool The default build generates a dynamic (dll/so) library. Set this to OFF to create a static library only.
BUILD_STATIC_LIBS Bool The default build generates a static (lib/a) library. Set this to OFF to create a shared library only.
DISABLE_STATIC_FPIC Bool The default builds position independent code. Set this to OFF to create a shared library only.
DISABLE_BSYMBOLIC Bool Disable use of -Bsymbolic-functions.
DISABLE_THREAD_LOCAL_STORAGE Bool Disable use of Thread-Local Storage (HAVE___THREAD).
DISABLE_WERROR Bool Disable use of -Werror.
ENABLE_RDRAND Bool Enable RDRAND Hardware RNG Hash Seed.
ENABLE_THREADING Bool Enable partial threading support.
OVERRIDE_GET_RANDOM_SEED String A block of code to use instead of the default implementation of json_c_get_random_seed(), e.g. on embedded platforms where not even the fallback to time() works. Must be a single line.

Pass these options as -D on CMake's command-line.

# build a static library only
cmake -DBUILD_SHARED_LIBS=OFF ..

Building with partial threading support

Although json-c does not support fully multi-threaded access to object trees, it has some code to help make its use in threaded programs a bit safer. Currently, this is limited to using atomic operations for json_object_get() and json_object_put().

Since this may have a performance impact, of at least 3x slower according to https://stackoverflow.com/a/11609063, it is disabled by default. You may turn it on by adjusting your cmake command with: -DENABLE_THREADING=ON

Separately, the default hash function used for object field keys, lh_char_hash, uses a compare-and-swap operation to ensure the random seed is only generated once. Because this is a one-time operation, it is always compiled in when the compare-and-swap operation is available.

cmake-configure wrapper script

For those familiar with the old autoconf/autogen.sh/configure method, there is a cmake-configure wrapper script to ease the transition to cmake.

mkdir build
cd build
../cmake-configure --prefix=/some/install/path
make

cmake-configure can take a few options.

options Description
prefix=PREFIX install architecture-independent files in PREFIX
enable-threading Enable code to support partly multi-threaded use
enable-rdrand Enable RDRAND Hardware RNG Hash Seed generation on supported x86/x64 platforms.
enable-shared build shared libraries [default=yes]
enable-static build static libraries [default=yes]
disable-Bsymbolic Avoid linking with -Bsymbolic-function
disable-werror Avoid treating compiler warnings as fatal errors

Testing:

By default, if valgrind is available running tests uses it. That can slow the tests down considerably, so to disable it use:

export USE_VALGRIND=0

To run tests a separate build directory is recommended:

mkdir build-test
cd build-test
# VALGRIND=1 causes -DVALGRIND=1 to be passed when compiling code
# which uses slightly slower, but valgrind-safe code.
VALGRIND=1 cmake ..
make

make test
# By default, if valgrind is available running tests uses it.
make USE_VALGRIND=0 test   # optionally skip using valgrind

If a test fails, check Testing/Temporary/LastTest.log, tests/testSubDir/${testname}/${testname}.vg.out, and other similar files. If there is insufficient output try:

VERBOSE=1 make test

or

JSONC_TEST_TRACE=1 make test

and check the log files again.

Building on Unix and Windows with vcpkg

You can download and install JSON-C using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install json-c

The JSON-C port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Linking to libjson-c

If your system has pkgconfig, then you can just add this to your makefile:

CFLAGS += $(shell pkg-config --cflags json-c)
LDFLAGS += $(shell pkg-config --libs json-c)

Without pkgconfig, you would do something like this:

JSON_C_DIR=/path/to/json_c/install
CFLAGS += -I$(JSON_C_DIR)/include/json-c
LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c

Using json-c

To use json-c you can either include json.h, or preferrably, one of the following more specific header files:

  • json_object.h - Core types and methods.
  • json_tokener.h - Methods for parsing and serializing json-c object trees.
  • json_pointer.h - JSON Pointer (RFC 6901) implementation for retrieving objects from a json-c object tree.
  • json_object_iterator.h - Methods for iterating over single json_object instances. (See also json_object_object_foreach() in json_object.h)
  • json_visit.h - Methods for walking a tree of json-c objects.
  • json_util.h - Miscellaneous utility functions.

For a full list of headers see files.html

The primary type in json-c is json_object. It describes a reference counted tree of json objects which are created by either parsing text with a json_tokener (i.e. json_tokener_parse_ex()), or by creating (with json_object_new_object(), json_object_new_int(), etc...) and adding (with json_object_object_add(), json_object_array_add(), etc...) them individually. Typically, every object in the tree will have one reference, from its parent. When you are done with the tree of objects, you call json_object_put() on just the root object to free it, which recurses down through any child objects calling json_object_put() on each one of those in turn.

You can get a reference to a single child (json_object_object_get() or json_object_array_get_idx()) and use that object as long as its parent is valid.
If you need a child object to live longer than its parent, you can increment the child's refcount (json_object_get()) to allow it to survive the parent being freed or it being removed from its parent (json_object_object_del() or json_object_array_del_idx())

When parsing text, the json_tokener object is independent from the json_object that it returns. It can be allocated (json_tokener_new()) used one or multiple times (json_tokener_parse_ex(), and freed (json_tokener_free()) while the json_object objects live on.

A json_object tree can be serialized back into a string with json_object_to_json_string_ext(). The string that is returned is only valid until the next "to_json_string" call on that same object. Also, it is freed when the json_object is freed.

Comments
  • Please undeprecate json_object_object_get

    Please undeprecate json_object_object_get

    One of the great advantages of using json-c is to have very little code to write. Now with this json_object_object_get deprecation, we have to change:

    int timeout = json_object_get_int(json_object_object_get(request, "timeout"));
    

    to this:

    int timeout;
    {
        json_object * jTimeout;
        if ( json_object_object_get_ex(request, "timeout", & jTimeout) ) {
            timeout = json_object_get_int(jTimeout);
        } else {
            timeout = 0
        }
    }
    

    same thing for strings. We cannot do:

    const char * name = json_object_get_string( json_object_object_get(request, "name"));
    

    Sure, it relies on the fact that the API is nice enough to accept NULL object to the json_object_get_int and json_object_get_string functions.

    And sure we can make our own wrapper:

    json_object * json_object_object_get_old(json_object * obj, const char * name) {
        json_object * sub;
        return json_object_object_get_ex(obj, name, & sub) ? sub : NULL;
    }
    

    But I don't understand why you decided to remove something in the API that forces us to write more code.

    opened by fclairamb 22
  • Some subsequent call of lh_get_hash not working

    Some subsequent call of lh_get_hash not working

    5u4

    Hello,

    using platform : Renesas Synergy S5D9 ( some Cortex M4)

    I have succesfully integrated the framework and it is working absolutely just how it is supposed to when the device is running with the external debugger. But when I run the firmware in "release mode" ( no debugger/ same configuration) the devices crashes somewhere after calling lh_get_hash. No watchdogs are being used, same configuration and everything for both use cases. Is there anything known about running the framework on embedded devices ? Some type of semi_hosting that doesn't exist when the device runs without debugger ? Does any workaround exist ? ( skipping the lh for example?)

    I don't really know what to look for if I had to debug the programm myself, I don't even have a proper way to debug it, since the only way I can follow some paths is by turning led's on and off :( .

    Any advice will be greatfully apreciated !

    Best regards

    opened by robybeen 16
  • compatibility issue with libjson shim in autoconf

    compatibility issue with libjson shim in autoconf

    I installed json-c with brew install json-c and it created the shims:

    ls -l
    ...
    libjson.0.dylib
    libjson.dylib -> libjson.0.dylib
    ...
    

    However in the autoconf tool when it does:

    ...
    AC_CHECK_LIB([json], [json_object_get], [HAVE_JSON=yes], [], [])
    ...
    

    it fails to find the function json_object_get in the libjson library.

    opened by kashif 16
  • json-c and jansson libraries have symbol conflicts

    json-c and jansson libraries have symbol conflicts

    Describe the bug In the application, we are using a shared library which is using json-c for its internal purpose. Later our application required to use a third party library, but its internally used jansson inside it for its functionality. Unfortunately when we run the application , it leads to memory corruption and process crashed.

    Both of these libraries have multiple APIs with same name but different signature. Due to this, there is a memory corruption that resulted in crash.

    The following APIs are available in both json-c and jansson libraries with the same name: json_object_get
    json_object_iter_next

    Steps To Reproduce This issue can easily reproduce with the following way:

    • Application linked to libjson_c_lib.so and libjansson_c_lib.so. Both of these are wrapper libraries are using json-c and jannson internally.

    • libjson_c_so wrapper library linked to libjson-c.so

    • libjansson_c.so wrapper library linked to libjansson.so.

    Tried statically linked one of the library but its not helped here. If we statically link jansson to wrapper library, json-c calls failed especially json_tokener_parse(). If we statically link json-c library, its resulted in same memory corruption.

    opened by vysakh-av 15
  • MSVC linker error json_c_strerror

    MSVC linker error json_c_strerror

    This is probably related to #336

    I link my cross-platform program (Linux/Mac/Windows) with json-c.

    Today I updated and rebuilt json-c from master. Mac and Linux builds are ok, on Windows I get the following error:

    error LNK2019: unresolved external symbol __json_c_strerror referenced in function __json_object_to_fd

    The json-c library itself has been built successfully, but my program that links with it fails to be built now.

    Using MSVC 14 (2015), 32-bit build, both Debug and Release fail.

    I rolled back to this commit: c0b7d762b28d3ddc4dbaa4e8a27ba7c33d54d2d5, rebuilt json-c and after that I was able to link my program with it successfully.

    opened by alexukr 15
  • Switch json-c builds to use CMake

    Switch json-c builds to use CMake

    As @guru-florida suggested in Issue #308: Why not just switch to CMake? It isnt that hard to setup and I find real cmake builds always work and autoconf is usually a PITA.

    https://github.com/guru-florida/json-c

    I'm expecting to merge over these changes after the next json-c release. (See Issue #314)

    new-feature 
    opened by hawicz 15
  • Sometimes a double value is not serialized

    Sometimes a double value is not serialized

    We have seen twice now error messages where json-c has failed parsing a json file written by the same app (and thus json-c). In both cases the files got invalid syntax, as one double value had not been serialized, like the missing width value in the example below.

    .... “size”: { “width”: , “height”: 0.5 }, ....

    It happens very seldom, and was detected by automated testing in both cases.

    opened by Ekmansoft 14
  • crash perhaps related to reference counting

    crash perhaps related to reference counting

    Hi, I have a json child node object that originates in a given parent object. This node gets added, as a child node, a number of times (using pointer reference) to other json objects. Each of one of those "other" objects gets a "put" as they get terminated. Finally, the parent also gets a "put" at the end of the cycle. I seem to get random crashes under this scenario. What's the correct way to handle the above?

    Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7fffebfff700 (LWP 5190)] 0x00007fffec0827f8 in ?? () (gdb) where #0 0x00007fffec0827f8 in ?? () #1 0x00007ffff75967ce in json_object_put (jso=0x7fffec0827f0) at json_object.c:158 #2 json_object_put (jso=0x7fffec0827f0) at json_object.c:150 #3 0x00007ffff759a3f6 in lh_table_free (t=0x7fffec153150) at linkhash.c:485 #4 0x00007ffff759672d in json_object_object_delete (jso=0x7fffec153100)

    at json_object.c:354
    

    #5 0x00007ffff75967d4 in json_object_put (jso=0x7fffec153100) at json_object.c:159 #6 json_object_put (jso=0x7fffec153100) at json_object.c:150 #7 0x000000000043310c in proto_http_reset_session_callback (sesn_ptr=0x794db0,

    callflags=1) at protocol_http.c:220
    

    #8 0x000000000043f4f3 in SuspendThisSession (sesn_ptr_this=0x0,

    sesn_ptr_target=0x794db0, recycle_flag=1) at session.c:353
    

    #9 0x0000000000444f5e in CheckSessionIdleTime (arg=0x7c70d0) at session.c:3389 #10 0x0000000000465d42 in ThreadUFServerWorker (ptr=0x6d4b00)

    at worker_ufsrv_thread.c:188
    

    #11 0x00007ffff79bbb50 in start_thread (arg=) at pthread_create.c:304 #12 0x00007ffff5d3395d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112 #13 0x0000000000000000 in ?? ()

    opened by usergoodvery 14
  • Running tests with MinGW build

    Running tests with MinGW build

    I tried running tests with wine with the make check build, and ran into some issues.

    With these changes it worked: https://gist.github.com/braydonf/41091d8a63d111aa2d954dccb1ad0d56

    opened by braydonf 13
  • Please provide more precise informations about when to call json_object_put

    Please provide more precise informations about when to call json_object_put

    Hello,

    It's difficult to determine when to call json_object_put after json_obect_xxx calls. I found tons of questions about this and all examples and tutorials I found really don't care about correctly freeing the memory. And answers and not allways clear as it seems that doubts are widely shared.

    One example about json_object_parse_ex in your documentation, you effectively specify that an object is returned so we can logically think that a call to json_object_put is necessary but a clearer notice would be fine all the more the given code snippet doesn't mention json_object_put call. Maybe json_object_put documentation could give the list of the functions supposed to need this call. I understand it's maybe not so simple as some functions transfer ownership and so, if I well understand because it's also not so obvious, doesn't wait from freeing the object from theirself.

    What json_tokener_freedo ??

    Some functions increment ownership such as json_object_get is it the only one? Can json_object_get be called other function, like json_tokern_parse for example? And so is there an json_object_count to call json_object_put until 0?

    Often, functions which doesn't change increment count specify that there is no need to call json_object_put except for special situation. But the ones which need it don't tell anything such as json_object_get even if it souds obvious for you.

    And itseems that the documentation refers to 0.10 version.

    Thanks in advance.

    opened by fralbo 12
  • Hang/Crash with large strings

    Hang/Crash with large strings

    I am using v0.12.1. I am seeing that very large strings are causing the tokener code to hang. I'm not exactly sure what the size cutoff is that is causing the issue because I don't control the code sending the messages. I have seen packets 300-500 bytes/characters long. The string that I"m working on now though is 1298 bytes/characters.

    Is there a max length that is supported by json_c?

    Here is a snippet of my code and where things hang up:

        json_tokener* tok;
        tok = json_tokener_new();
        jsonObj = json_tokener_parse_ex(tok, i_strToParse, i_length);
    

    Initially I had this, which worked for the smaller strings. jsonObj = json_tokener_parse( i_strToParse );

    I even tried calling json_tokener_new_ex() and passing a specific depth thinking that possibly it was allocating too much space. That made no difference.

    I have to be doing something wrong, but I'm not sure what. The above code works for all of the other strings that I am trying to parse. Any help/guidance is appreciated.

    opened by terryopie 12
  • Allow arrays to be pretty-printed with more than one element per line.

    Allow arrays to be pretty-printed with more than one element per line.

    Feature Request When json-c converts a json array to a json string and the flag 'JSON_C_TO_STRING_PRETTY' is used, it inserts a newline after every array element.

    If the array is a long array filled with integers, it can be tedious to scroll down to view the entire array.
    A good solution would be to use the default flag 'JSON_C_TO_STRING_PLAIN' to print the array all on one line. But if the array is nested within a json object that includes other objects that are not arrays then the 'JSON_C_TO_STRING_PRETTY' flag seems to be needed to preserve the pretty formatting for the other objects.

    Example:

    {
      "test1":{
        "test2":{
          "test3":"test3"
        }
      },
      "my_long_array":[
        0,
        1,
        2,
        3,
        4,
        5,
    <snip>
        250,
        251,
        252,
        253,
        254
      ]
    }
    

    Steps To Reproduce

    json_object *parent = json_object_new_object();
    struct json_object *test1 = json_object_new_object();
    struct json_object *test2 = json_object_new_object();
    json_object_object_add(test2, "test3", json_object_new_string("test3"));
    json_object_object_add(test1, "test2", test2);
    json_object_object_add(parent, "test1", test1);
    
    json_object *my_long_array = json_object_new_array();
    for (int i = 0; i < 255; i++)
    	json_object_array_add(my_long_array, json_object_new_int(i));
    json_object_object_add(parent, "my_long_array", my_long_array);
    
    printf("%s\n", json_object_to_json_string_ext(parent, JSON_C_TO_STRING_PRETTY));
    

    Would it be possible to have a new pretty-print format that prints n-number of array elements per line? While still preserving pretty format for the non-array objects within an object? So the result would look something like this:

    {
      "test1":{
        "test2":{
          "test3":"test3"
        }
      },
      "my_long_array":[
        0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,
        30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,
        57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,
        84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,
        108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
        128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,
        148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,
        168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
        188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
        208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,
        228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,
        248,249,250,251,252,253,254
        ]
    }
    

    Version and Platform

    • json-c version: json-c 0.16-1
    • OS: Arch
    • Custom cmake/build flags: none
    opened by dbrouwer3563 1
  • Unnecessary struct declaration and unsafe function usage

    Unnecessary struct declaration and unsafe function usage

    Struct 'json_object' forward declaration unnecessary, already declared. Please delete it. According to standards for C Language, high Risk to use strcat() in json_object.c . It should be replaced by strncat. High Risk to use vsprintf(). It should be replaced by vsnprintf.

    opened by EibzChan 1
  • The function add_compile_options was added to CMake version 2.8.12 and later but your minimum is 2.8 which will not work

    The function add_compile_options was added to CMake version 2.8.12 and later but your minimum is 2.8 which will not work

    Describe the bug Will not build with CMAKE prior to version 2.8.12

    Steps To Reproduce Try to build with version CMAKE < 2.8.12

    Version and Platform

    • json-c version: [e.g. json-c-0.15, or a specific commit hash]
    • OS: [e.g. Ubuntu 18.04.6, ]
    • cmake version 2.8.4
    opened by nicebub 4
  • add JSON_C_TO_STRING_COLOR option

    add JSON_C_TO_STRING_COLOR option

    This option enable color in json_object_to_json_string_ext. I've try to made something similar to jq output, but I color true/false and null in purple, as it's what is common color scheme used in programing language in emacs.

    also add a '-c' option into json_parser to test it.

    note: that I could have done a color() function similar to what is done with indent(), but as the code is pretty small I've keep it as it. so if you want me to use a subfunction tell me and I'll do it.

    Signed-off-by: Matthias Gatto [email protected]

    opened by cosmo-ray 0
  • Some people have trouble with undefined references to arc4random

    Some people have trouble with undefined references to arc4random

    Note: for general questions and comments, please use the forums at: https://groups.google.com/g/json-c

    Describe the bug On some systems, json-c uses arc4random(), but then the linker fails to find it. See e.g. messages from @nmartin-cs and @moonburnt at https://github.com/json-c/json-c/issues/692#issuecomment-793057630

    Steps To Reproduce

    mkdir build && cd $_
    cmake ..
    cmake -DCMAKE_INSTALL_PREFIX=/usr .
    sudo make install  
    

    Version and Platform Arch Linux 5.10.13, glibc 2.33-3, gcc 10.2.0, cmake

    opened by hawicz 6
  • json_tokener_parse_ex: handle out of memory errors

    json_tokener_parse_ex: handle out of memory errors

    Do not silently truncate values or skip entries if out of memory errors occur.

    Proof of Concept:

    • Create poc.c, a program which creates an eight megabyte large json object with key "A" and a lot of "B"s as value, one of them is UTF-formatted:
     #include <err.h>
     #include <stdio.h>
     #include <string.h>
    
     #include "json.h"
    
     #define STR_LEN (8 * 1024 * 1024)
     #define STR_PREFIX "{ \"A\": \""
     #define STR_SUFFIX "\\u0042\" }"
    
    int main(void) {
      char *str;
      struct json_tokener *tok;
      struct json_object *obj;
    
      if ((tok = json_tokener_new()) == NULL)
        errx(1, "json_tokener_new");
    
      if ((str = malloc(STR_LEN)) == NULL)
        err(1, "malloc");
      memset(str, 'B', STR_LEN);
      memcpy(str, STR_PREFIX, sizeof(STR_PREFIX) - 1);
      memcpy(str + STR_LEN - sizeof(STR_SUFFIX), STR_SUFFIX, sizeof(STR_SUFFIX));
    
      obj = json_tokener_parse(str);
      free(str);
    
      printf("%p\n", obj);
      if (obj != NULL) {
        printf("%.*s\n", 50, json_object_to_json_string(obj));
        json_object_put(obj);
      }
    
      json_tokener_free(tok);
      return 0;
    }
    
    • Compile and run poc, assuming you have enough free heap space:
    gcc $(pkg-config --cflags --libs) -o poc poc.c
    ./poc
    0x559421e15de0
    { "A": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
    
    • Reduce available heap and run again, which leads to truncation:
    ulimit -d 10000
    ./poc
    0x555a5b453de0
    { "A": "B" }
    
    • Compile json-c with this change and run with reduced heap again:
    ulimit -d 10000
    ./poc
    (nil)
    

    The output is limited to 50 characters, i.e. json-c parses the 8 MB string correctly but the poc does not print all of them to the screen.

    The truncation occurs because the parser tries to add all chars up to the UTF-8 formatted 'B' at once. Since memory is limited to 10 MB there is not enough for this operation. The parser does not fail but continues normally.

    Another possibility is to create a json file close to 2 GB and run a program on a system with limited amount of RAM, i.e. around 3 GB. But ulimit restrictions are much easier for proof of concepts.

    Treat memory errors correctly and abort operations.

    opened by stoeckmann 0
Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket

JSMN jsmn (pronounced like 'jasmine') is a minimalistic JSON parser in C. It can be easily integrated into resource-limited or embedded projects. You

Serge Zaitsev 3.2k Jan 9, 2023
jstruct is an automatic C code generation tool for generating JSON parsing and stringifying code.

jstruct is an automatic C code generation tool for generating JSON parsing and stringifying code. The C code generated by this tool needs to depend on the cJSON library for execution.

acoinfo 28 Dec 30, 2022
A fast JSON parser/generator for C++ with both SAX/DOM style API

A fast JSON parser/generator for C++ with both SAX/DOM style API Tencent is pleased to support the open source community by making RapidJSON available

Tencent 12.6k Dec 30, 2022
A generator of JSON parser & serializer C++ code from structure header files

JSON-CPP-gen This is a program that parses C++ structures from a header file and automatically generates C++ code capable of serializing said structur

Viktor Chlumský 12 Oct 13, 2022
json-cpp is a C++11 JSON serialization library.

JSON parser and generator for C++ Version 0.1 alpha json-cpp is a C++11 JSON serialization library. Example #include <json-cpp.hpp> struct Foo {

Anatoly Scheglov 7 Oct 30, 2022
This is a JSON C++ library. It can write and read JSON files with ease and speed.

Json Box JSON (JavaScript Object Notation) is a lightweight data-interchange format. Json Box is a C++ library used to read and write JSON with ease a

Anhero inc. 110 Dec 4, 2022
A convenience C++ wrapper library for JSON-Glib providing friendly syntactic sugar for parsing JSON

This library is a wrapper for the json-glib library that aims to provide the user with a trivial alternative API to the API provided by the base json-

Rob J Meijer 17 Oct 19, 2022
json-build is a zero-allocation JSON serializer compatible with C89

json-build is a zero-allocation JSON serializer compatible with C89. It is inspired by jsmn, a minimalistic JSON tokenizer.

Lucas Müller 31 Nov 16, 2022
Ultralightweight JSON parser in ANSI C

cJSON Ultralightweight JSON parser in ANSI C. Table of contents License Usage Welcome to cJSON Building Copying the source CMake Makefile Vcpkg Includ

Dave Gamble 8.3k Jan 4, 2023
JSON parser and generator for C/C++ with scanf/printf like interface. Targeting embedded systems.

JSON parser and emitter for C/C++ Features ISO C and ISO C++ compliant portable code Very small footprint No dependencies json_scanf() scans a string

Cesanta Software 637 Dec 30, 2022
C library for encoding, decoding and manipulating JSON data

Jansson README Jansson is a C library for encoding, decoding and manipulating JSON data. Its main features and design principles are: Simple and intui

Petri Lehtinen 2.7k Dec 31, 2022
JSON & BSON parser/writer

jbson is a library for building & iterating BSON data, and JSON documents in C++14. \tableofcontents Features # {#features} Header only. Boost license

Chris Manning 40 Sep 14, 2022
A very sane (header only) C++14 JSON library

JeayeSON - a very sane C++14 JSON library JeayeSON was designed out of frustration that there aren't many template-based approaches to handling JSON i

Jeaye Wilkerson 128 Nov 28, 2022
JSON for Modern C++

Design goals Sponsors Integration CMake Package Managers Pkg-config Examples JSON as first-class data type Serialization / Deserialization STL-like ac

Niels Lohmann 33.2k Jan 4, 2023
A JSON parser in C++

JSON++ Introduction JSON++ is a light-weight JSON parser, writer and reader written in C++. JSON++ can also convert JSON documents into lossless XML d

Hong Jiang 498 Dec 28, 2022
🗄️ single header json parser for C and C++

??️ json.h A simple single header solution to parsing JSON in C and C++. JSON is parsed into a read-only, single allocation buffer. The current suppor

Neil Henning 544 Jan 7, 2023
A C++ library for interacting with JSON.

JsonCpp JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value p

null 6.9k Dec 31, 2022
Very low footprint JSON parser written in portable ANSI C

Very low footprint JSON parser written in portable ANSI C. BSD licensed with no dependencies (i.e. just drop the C file into your project) Never recur

James McLaughlin 1.2k Jan 5, 2023
A tiny JSON library for C++11.

json11 json11 is a tiny JSON library for C++11, providing JSON parsing and serialization. The core object provided by the library is json11::Json. A J

Dropbox 2.4k Dec 31, 2022