C library for encoding, decoding and manipulating JSON data

Related tags

JSON c json
Overview

Jansson README

https://ci.appveyor.com/api/projects/status/lmhkkc4q8cwc65ko https://coveralls.io/repos/akheron/jansson/badge.png?branch=master

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

  • Simple and intuitive API and data model
  • Comprehensive documentation
  • No dependencies on other libraries
  • Full Unicode support (UTF-8)
  • Extensive test suite

Jansson is licensed under the MIT license; see LICENSE in the source distribution for details.

Compilation and Installation

You can download and install Jansson using the vcpkg dependency manager:

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

The Jansson 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.

If you obtained a source tarball from the "Releases" section of the main site just use the standard autotools commands:

$ ./configure
$ make
$ make install

To run the test suite, invoke:

$ make check

If the source has been checked out from a Git repository, the ./configure script has to be generated first. The easiest way is to use autoreconf:

$ autoreconf -i

Documentation

Documentation is available at http://jansson.readthedocs.io/en/latest/.

The documentation source is in the doc/ subdirectory. To generate HTML documentation, invoke:

$ make html

Then, point your browser to doc/_build/html/index.html. Sphinx 1.0 or newer is required to generate the documentation.

Issues
  • build: Add a symbol version to all exported symbols

    build: Add a symbol version to all exported symbols

    The --default-symver linker option attaches a default version definition (the SONAME) to every exported symbol. It is supported since at least GNU binutils 2.22 in 2011 (older versions not tested).

    With this version definition, newly-linked binaries that depend on the jansson shared library will refer to its symbols in a versioned form, preventing their references from being resolved to a symbol of the same name exported by json-c or json-glib if those libraries appear in dependency search order before jansson, which will usually result in a crash. This is necessary because ELF symbol resolution normally uses a single flat namespace, not a tree like Windows symbol resolution. At least one symbol (json_object_iter_next()) is exported by all three JSON libraries.

    Linking with -Bsymbolic is not enough to have this effect in all cases, because -Bsymbolic only affects symbol lookup within a shared object, for example when parse_json() calls json_decref(). It does not affect calls from external code into jansson, unless jansson was statically linked into the external caller.

    This change will also not prevent code that depends on json-c or json-glib from finding jansson's symbols and crashing; to prevent that, a corresponding change in json-c or json-glib would be needed.

    Adding a symbol-version is a backwards-compatible change, but once added, removing or changing the symbol-version would be an incompatible change that requires a SONAME bump.

    Resolves: https://github.com/akheron/jansson/issues/523 (when combined with an equivalent change to json-c).


    I am not a jansson expert, please review and test carefully.

    opened by smcv 21
  • ORing flags together

    ORing flags together

    Can someone give me an example of ORing flags together? I'm trying to use JSON_INDENT and JSON_REAL_PRECISION, but I don't have a clue what it meant by ORing something. Thanks ahead of time.

    opened by WillLuce 18
  • oss-fuzz: Create a fuzzing target for jansson

    oss-fuzz: Create a fuzzing target for jansson

    Hi! I've been adding oss-fuzz support to some open-source projects (lz4, curl) and thought that I'd offer a fix for issue #479 raised by @Google-Autofuzz.

    This takes the sample code they offered and puts it into your build tree. To actually get it into oss-fuzz you'll need to submit a patch in the oss-fuzz project; if this is something you're interested in I have a code branch ready to submit (just needs a contact email address for any bugs that it finds).

    re: the raw Make commands: Annoyingly they've recently changed the behaviour of the LIB_FUZZING_ENGINE variable (it used to be a file, now its value is "-fsanitizer=fuzzer" (so now is a flag). The Make commands here mean that you can build a testcase loader without having to have that set up.

    opened by cmeister2 13
  • Cmake for master

    Cmake for master

    I also have a branch for adding cmake to version 2.3, if you are interested.

    I don't expect you to pull this into your master, but it would be nice if you pulled it into a branch and give it a try. It detects a few extra things properly that your automake system doesn't (yet).

    It should allow you to build with cmake, or build with autotools, with the same tree. Its not a disruptive change, and I prefer using cmake to using the supplied MSVC project files (I've been down that path before with other projects, its annoying).

    cheers :)

    opened by paulharris 13
  • Add json_object_update_recursive()

    Add json_object_update_recursive()

    Support merging values nested within objects. For instance, merging:

        {
    	"foo": 1,
    	"bar": {
    	    "baz": 2
    	}
        }
    

    with

        {
    	"bar": {
    	    "baz": 3
    	}
        }
    

    results in

        {
    	"foo": 1,
    	"bar": {
    	    "baz": 3
    	}
        }
    

    instead of overwriting the value for the bar key.

    opened by hmpcabral 11
  • Add jansson command

    Add jansson command

    The jansson command is a utility for building and parsing JSON objects from the CLI. It is a simple stack machine on which operations can be performed. This command exposes the most important Jansson APIs.

    opened by npmccallum 11
  • Add json_load_callback()

    Add json_load_callback()

    Some embedded operation system only provide direct interface for file I/O, i.e. not supporting the native fopen()/fread() API. So I have to create a json_load_callback() wrapping to allow flexible input.

    As we've already have a json_dump_callback(), it might be interesting for jansson to have one for loading too.

    Update: tab space mixture fixed

    opened by rogerz 11
  • Build: Add JANSSON_ATTRS macro.

    Build: Add JANSSON_ATTRS macro.

    This macro is used to conditionally generate GCC/CLANG attribute declarations if supported.

    This allows the compiler to produce warnings on certain incorrect usages. json_sprintf and json_vsprintf will produce warnings on invalid format string. Many functions will produce a warning if the result is unused. Specifically functions which allocate new objects will warn if the result is ignored as this always results in a memory leak.

    opened by coreyfarrell 10
  • Preserve insertion order in objects

    Preserve insertion order in objects

    My application requires that objects preserve the order of elements when parsed. This modifies the hashtable code to also maintain a linked list of struct hashtable_pair pointers, in the order they are added to the hashtable. Iterator operations now use this instead.

    It adds a bit more space to hashtables and key/value pairs, and adds a list append/remove operation on putting a new value, or deleting a value.

    It does not modify the order on update: it preserves creation order, not update order.

    I kind of butchered linked list handling. I couldn't break out of the "NULL terminates the list" mode of thinking, at least for append-only lists.

    feature 
    opened by csm 10
  • SIGSEV at  hashtable_find_pair

    SIGSEV at hashtable_find_pair

    Hi, i've noticed that firewalld-0.8.1 started to coredumps on OpenMandriva Linux distribution:

    Here are the logs

    [[email protected] tpg]# coredumpctl debug 689                 
               PID: 689 (firewalld)
               UID: 0 (root)
               GID: 0 (root)
            Signal: 11 (SEGV)
         Timestamp: Thu 2020-01-30 14:32:45 CET (14min ago)
      Command Line: /usr/bin/python /usr/sbin/firewalld --nofork --nopid
        Executable: /usr/bin/python3.8
     Control Group: /system.slice/firewalld.service
              Unit: firewalld.service
             Slice: system.slice
           Boot ID: df6c6a86ce5246baa0cbb48107efd6c2
        Machine ID: 8e3f63c507904cf4b2186f8e6939f94c
          Hostname: tpg-virtualbox
           Storage: /var/lib/systemd/coredump/core.firewalld.0.df6c6a86ce5246baa0cbb48107efd6c2.689.1580391165000000000000.lz4
           Message: Process 689 (firewalld) of user 0 dumped core.
                    
                    Stack trace of thread 689:
                    #0  0x00007fa5920cba3f hashtable_find_pair (libjansson.so.4 + 0x6a3f)
                    #1  0x00007fa5920cbac5 hashtable_get (libjansson.so.4 + 0x6ac5)
                    #2  0x00007fa5920cf449 unpack (libjansson.so.4 + 0xa449)
                    #3  0x00007fa5920ceb48 json_vunpack_ex (libjansson.so.4 + 0x9b48)
                    #4  0x00007fa5920cf980 json_unpack (libjansson.so.4 + 0xa980)
                    #5  0x00007fa592185eef __json_parse (libnftables.so.1.0.0 + 0x70eef)
                    #6  0x00007fa59217c010 nft_run_cmd_from_buffer (libnftables.so.1.0.0 + 0x67010)
                    #7  0x00007fa5930af13d n/a (libffi.so.7 + 0x313d)
                    #8  0x00007fa5930b3f02 n/a (libffi.so.7 + 0x7f02)
                    #9  0x00007fa592953faa _ctypes_callproc (_ctypes.cpython-38-x86_64-linux-gnu.so + 0x15faa)
                    #10 0x00007fa59294ed71 PyCFuncPtr_call (_ctypes.cpython-38-x86_64-linux-gnu.so + 0x10d71)
                    #11 0x00007fa596c649f7 _PyObject_MakeTpCall (libpython3.8.so.1.0 + 0x17e9f7)
                    #12 0x00007fa596d89924 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3924)
                    #13 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #14 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #15 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #16 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #17 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #18 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #19 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #20 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #21 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #22 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #23 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #24 0x00007fa596c6617f _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x18017f)
                    #25 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #26 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #27 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #28 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #29 0x00007fa596c65478 PyVectorcall_Call (libpython3.8.so.1.0 + 0x17f478)
                    #30 0x00007fa596d89e7a _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3e7a)
                    #31 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #32 0x00007fa596c6617f _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x18017f)
                    #33 0x00007fa596d89a17 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3a17)
                    #34 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #35 0x00007fa596d896f6 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a36f6)
                    #36 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #37 0x00007fa596c6617f _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x18017f)
                    #38 0x00007fa596c65478 PyVectorcall_Call (libpython3.8.so.1.0 + 0x17f478)
                    #39 0x00007fa596d89e7a _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3e7a)
                    #40 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #41 0x00007fa596c6617f _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x18017f)
                    #42 0x00007fa596c65478 PyVectorcall_Call (libpython3.8.so.1.0 + 0x17f478)
                    #43 0x00007fa596d89e7a _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3e7a)
                    #44 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #45 0x00007fa596c6617f _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x18017f)
                    #46 0x00007fa596c646d6 _PyObject_FastCallDict (libpython3.8.so.1.0 + 0x17e6d6)
                    #47 0x00007fa596ce52fd slot_tp_init (libpython3.8.so.1.0 + 0x1ff2fd)
                    #48 0x00007fa596ceed24 type_call (libpython3.8.so.1.0 + 0x208d24)
                    #49 0x00007fa596c649f7 _PyObject_MakeTpCall (libpython3.8.so.1.0 + 0x17e9f7)
                    #50 0x00007fa596d89b05 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3b05)
                    #51 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #52 0x00007fa596c6617f _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x18017f)
                    #53 0x00007fa596d898af _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a38af)
                    #54 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #55 0x00007fa596d89a17 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3a17)
                    #56 0x00007fa596c66216 _PyFunction_Vectorcall (libpython3.8.so.1.0 + 0x180216)
                    #57 0x00007fa596d89a17 _PyEval_EvalFrameDefault (libpython3.8.so.1.0 + 0x2a3a17)
                    #58 0x00007fa596d7feab _PyEval_EvalCodeWithName (libpython3.8.so.1.0 + 0x299eab)
                    #59 0x00007fa596de7770 run_eval_code_obj (libpython3.8.so.1.0 + 0x301770)
                    #60 0x00007fa596de76bd run_mod (libpython3.8.so.1.0 + 0x3016bd)
                    #61 0x00007fa596de52a7 PyRun_FileExFlags (libpython3.8.so.1.0 + 0x2ff2a7)
                    #62 0x00007fa596de4ae7 PyRun_SimpleFileExFlags (libpython3.8.so.1.0 + 0x2feae7)
                    #63 0x00007fa596e0e0bc pymain_run_file (libpython3.8.so.1.0 + 0x3280bc)
    
    GNU gdb (GDB) 9.0.90.20191228-1 (OpenMandriva Lx release 4.1)
    Copyright (C) 2019 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.
    Type "show copying" and "show warranty" for details.
    This GDB was configured as "x86_64-openmandriva-linux-gnu".
    Type "show configuration" for configuration details.
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>.
    Find the GDB manual and other documentation resources online at:
        <http://www.gnu.org/software/gdb/documentation/>.
    
    For help, type "help".
    Type "apropos word" to search for commands related to "word"...
    Reading symbols from /usr/bin/python3.8...
    Reading symbols from /usr/lib/debug/usr/bin/python3.8-3.8.1-3.x86_64.debug...
    
    warning: core file may not match specified executable file.
    [New LWP 689]
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/lib64/libthread_db.so.1".
    
    warning: the debug information found in "/usr/lib/debug//usr/lib64/libffi.so.7.1.0-3.3-1.x86_64.debug" does not match "/usr/lib64/libffi.so.7" (CRC mismatch).
    
    
    warning: the debug information found in "/usr/lib/debug//usr/lib64/libffi.so.7.1.0-3.3-1.x86_64.debug" does not match "/usr/lib64/libffi.so.7" (CRC mismatch).
    
    Core was generated by `/usr/bin/python /usr/sbin/firewalld --nofork --nopid'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  hashtable_find_pair () at hashtable.c:93
    93              if(pair->hash == hash && strcmp(pair->key, key) == 0)
    (gdb) bt full
    #0  hashtable_find_pair () at hashtable.c:93
    No locals.
    #1  0x00007fa5920cbac5 in hashtable_get () at hashtable.c:279
    No locals.
    #2  0x00007fa5920cf449 in json_object_get () at value.c:98
    No locals.
    #3  unpack_object () at pack_unpack.c:551
    No locals.
    #4  unpack () at pack_unpack.c:686
    No locals.
    #5  0x00007fa5920ceb48 in json_vunpack_ex () at pack_unpack.c:915
    No locals.
    #6  0x00007fa5920cf980 in json_unpack () at pack_unpack.c:948
    No locals.
    #7  0x00007fa592185eef in __json_parse () from /usr/lib64/libnftables.so.1.0.0
    No symbol table info available.
    #8  0x00007fa59217c010 in nft_run_cmd_from_buffer () from /usr/lib64/libnftables.so.1.0.0
    No symbol table info available.
    #9  0x00007fa5930af13d in ?? () from /usr/lib64/libffi.so.7
    No symbol table info available.
    #10 0x00007fa5930b3f02 in ?? () from /usr/lib64/libffi.so.7
    No symbol table info available.
    #11 0x00007fa592953faa in _call_function_pointer (flags=4353, pProc=0x7fa59217bef5 <nft_run_cmd_from_buffer>, avalues=0x7fff27d4a590, atypes=<optimized out>, restype=<optimized out>, 
        resmem=0x7fff27d4a5a0, argcount=2) at Modules/_ctypes/callproc.c:871
            _save = 0x592bb0
            error_object = 0x0
            cc = 2
            cif = {abi = FFI_UNIX64, nargs = 2, arg_types = 0x7fff27d4a580, rtype = 0x7fa592964f28, bytes = 0, flags = 6}
            space = <optimized out>
            temp = <optimized out>
            temp = <optimized out>
    #12 _ctypes_callproc (pProc=0x7fa59217bef5 <nft_run_cmd_from_buffer>, argtuple=0x0, flags=4353, argtypes=<optimized out>, restype=0x7d2fa0, checker=<optimized out>)
        at Modules/_ctypes/callproc.c:1199
            retval = 0x0
            n = 2
            argcount = 2
            args = 0x7fff27d4a5b0
            argtype_count = 5843888
            pa = <optimized out>
            i = <optimized out>
            rtype = <optimized out>
            resbuf = 0x7fff27d4a5a0
            avalues = 0x7fff27d4a590
            atypes = <optimized out>
    #13 0x00007fa59294ed71 in PyCFuncPtr_call (self=0x7fa59227cf40, inargs=0x7fa591fd3e00, kwds=0x0) at Modules/_ctypes/_ctypes.c:4181
            dict = <optimized out>
            pProc = 0x0
            restype = <optimized out>
            converters = <optimized out>
            checker = <optimized out>
    --Type <RET> for more, q to quit, c to continue without paging--
            argtypes = <optimized out>
            errcheck = 0x0
            numretvals = 0
            inoutmask = 0
            outmask = 0
            callargs = 0x7fa591fd3e00
            result = <optimized out>
    #14 0x00007fa596c649f7 in _PyObject_MakeTpCall () at Objects/call.c:159
    No locals.
    #15 0x00007fa596d89924 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:125
    No locals.
    #16 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #17 function_code_fastcall () at Objects/call.c:283
    No locals.
    #18 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #19 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #20 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #21 function_code_fastcall () at Objects/call.c:283
    No locals.
    #22 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #23 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #24 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #25 function_code_fastcall () at Objects/call.c:283
    No locals.
    #26 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #27 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #28 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #29 function_code_fastcall () at Objects/call.c:283
    No locals.
    #30 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #31 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #32 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #33 function_code_fastcall () at Objects/call.c:283
    No locals.
    #34 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #35 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    --Type <RET> for more, q to quit, c to continue without paging--
    No locals.
    #36 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #37 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #38 0x00007fa596c6617f in _PyFunction_Vectorcall () at Objects/call.c:435
    No locals.
    #39 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #40 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #41 function_code_fastcall () at Objects/call.c:283
    No locals.
    #42 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #43 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #44 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #45 function_code_fastcall () at Objects/call.c:283
    No locals.
    #46 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #47 0x00007fa596c65478 in PyVectorcall_Call () at Objects/call.c:199
    No locals.
    #48 0x00007fa596d89e7a in _PyEval_EvalFrameDefault () at Python/ceval.c:5034
    No locals.
    #49 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #50 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #51 0x00007fa596c6617f in _PyFunction_Vectorcall () at Objects/call.c:435
    No locals.
    #52 0x00007fa596d89a17 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #53 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #54 function_code_fastcall () at Objects/call.c:283
    No locals.
    #55 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #56 0x00007fa596d896f6 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #57 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #58 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #59 0x00007fa596c6617f in _PyFunction_Vectorcall () at Objects/call.c:435
    No locals.
    #60 0x00007fa596c65478 in PyVectorcall_Call () at Objects/call.c:199
    --Type <RET> for more, q to quit, c to continue without paging--
    No locals.
    #61 0x00007fa596d89e7a in _PyEval_EvalFrameDefault () at Python/ceval.c:5034
    No locals.
    #62 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #63 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #64 0x00007fa596c6617f in _PyFunction_Vectorcall () at Objects/call.c:435
    No locals.
    #65 0x00007fa596c65478 in PyVectorcall_Call () at Objects/call.c:199
    No locals.
    #66 0x00007fa596d89e7a in _PyEval_EvalFrameDefault () at Python/ceval.c:5034
    No locals.
    #67 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #68 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #69 0x00007fa596c6617f in _PyFunction_Vectorcall () at Objects/call.c:435
    No locals.
    #70 0x00007fa596c646d6 in _PyObject_FastCallDict () at Objects/call.c:96
    No locals.
    #71 0x00007fa596ce52fd in slot_tp_init () at Objects/call.c:887
    No locals.
    #72 0x00007fa596ceed24 in type_call () at Objects/typeobject.c:991
    No locals.
    #73 0x00007fa596c649f7 in _PyObject_MakeTpCall () at Objects/call.c:159
    No locals.
    #74 0x00007fa596d89b05 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:125
    No locals.
    #75 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #76 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #77 0x00007fa596c6617f in _PyFunction_Vectorcall () at Objects/call.c:435
    No locals.
    #78 0x00007fa596d898af in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #79 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #80 function_code_fastcall () at Objects/call.c:283
    No locals.
    #81 _PyFunction_Vectorcall () at Objects/call.c:410
    No locals.
    #82 0x00007fa596d89a17 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #83 0x00007fa596c66216 in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #84 function_code_fastcall () at Objects/call.c:283
    No locals.
    #85 _PyFunction_Vectorcall () at Objects/call.c:410
    --Type <RET> for more, q to quit, c to continue without paging--
    No locals.
    #86 0x00007fa596d89a17 in _PyEval_EvalFrameDefault () at ./Include/cpython/abstract.h:127
    No locals.
    #87 0x00007fa596d7feab in PyEval_EvalFrameEx () at Python/ceval.c:741
    No locals.
    #88 _PyEval_EvalCodeWithName () at Python/ceval.c:4298
    No locals.
    #89 0x00007fa596de7770 in PyEval_EvalCodeEx () at Python/ceval.c:4327
    No locals.
    #90 PyEval_EvalCode () at Python/ceval.c:718
    No locals.
    #91 run_eval_code_obj () at Python/pythonrun.c:1125
    No locals.
    #92 0x00007fa596de76bd in run_mod () at Python/pythonrun.c:1147
    No locals.
    #93 0x00007fa596de52a7 in PyRun_FileExFlags () at Python/pythonrun.c:1063
    No locals.
    #94 0x00007fa596de4ae7 in PyRun_SimpleFileExFlags () at Python/pythonrun.c:428
    No locals.
    #95 0x00007fa596e0e0bc in pymain_run_file () at Modules/main.c:381
    No locals.
    #96 0x00007fa596e0d606 in pymain_run_python () at Modules/main.c:565
    No locals.
    #97 0x00007fa596e0d404 in Py_RunMain () at Modules/main.c:644
    No locals.
    #98 0x00007fa596e0e9fc in pymain_main () at Modules/main.c:674
    No locals.
    #99 0x00007fa596e0ed17 in Py_BytesMain () at Modules/main.c:698
    No locals.
    #100 0x00007fa596927e6b in __libc_start_main (main=0x201150 <main>, argc=4, argv=0x7fff27d4ce38, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 
        stack_end=0x7fff27d4ce28) at ../csu/libc-start.c:308
            self = <optimized out>
            result = <optimized out>
            unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, -5808915208034097174, 2101248, 140733861645872, 0, 0, 5808756817232357354, 5776353614130145258}, mask_was_saved = 0}}, priv = {
                pad = {0x0, 0x0, 0x7fff27d4ce60, 0x7fa596f44150}, data = {prev = 0x0, cleanup = 0x0, canceltype = 668257888}}}
            not_first_call = <optimized out>
    #101 0x000000000020102a in _start () at ../sysdeps/x86_64/start.S:120
    No locals.
    (gdb) Quit
    
    
    
    opened by tpgxyz 9
  • jansson.h: suppress unused-function warnings

    jansson.h: suppress unused-function warnings

    Without this pragma, building with clang and -Wall I get the following:

    In file included from imap/mboxevent.c:53:
    /usr/local/cyruslibs/include/jansson.h:140:6: error: unused function 'json_decrefp' [-Werror,-Wunused-function]
    void json_decrefp(json_t **json)
         ^
    /usr/local/cyruslibs/include/jansson.h:186:41: error: unused function 'json_error_code' [-Werror,-Wunused-function]
    static JSON_INLINE enum json_error_code json_error_code(const json_error_t *e) {
                                            ^
    /usr/local/cyruslibs/include/jansson.h:228:5: error: unused function 'json_object_set' [-Werror,-Wunused-function]
    int json_object_set(json_t *object, const char *key, json_t *value)
        ^
    /usr/local/cyruslibs/include/jansson.h:234:5: error: unused function 'json_object_set_nocheck' [-Werror,-Wunused-function]
    int json_object_set_nocheck(json_t *object, const char *key, json_t *value)
        ^
    /usr/local/cyruslibs/include/jansson.h:240:5: error: unused function 'json_object_iter_set' [-Werror,-Wunused-function]
    int json_object_iter_set(json_t *object, void *iter, json_t *value)
        ^
    /usr/local/cyruslibs/include/jansson.h:255:5: error: unused function 'json_array_set' [-Werror,-Wunused-function]
    int json_array_set(json_t *array, size_t ind, json_t *value)
        ^
    /usr/local/cyruslibs/include/jansson.h:261:5: error: unused function 'json_array_append' [-Werror,-Wunused-function]
    int json_array_append(json_t *array, json_t *value)
        ^
    /usr/local/cyruslibs/include/jansson.h:267:5: error: unused function 'json_array_insert' [-Werror,-Wunused-function]
    int json_array_insert(json_t *array, size_t ind, json_t *value)
        ^
    

    And ditto everywhere else jansson.h is included. This patch has no effect on the code built, but allows callers to turn on full warnings safely with clang.

    opened by brong 9
  • json_error_code is not displayed in the documentation

    json_error_code is not displayed in the documentation

    Hello team,

    The description of json_error_code is not displayed in the latest(v.2.14) documentation.

    It was displayed in the documentation of v.2.13 (API reference - Error reporting - json_error_code).

    opened by nitomath 0
  • getting the above error while i tried installing

    getting the above error while i tried installing

    ./vcpkg install jansson Computing installation plan... A suitable version of cmake was not found (required v3.22.2). Downloading portable cmake v3.22.2... Downloading cmake... https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2-linux-x86_64.tar.gz -> /home/abhinav/Downloads/vcpkg/downloads/cmake-3.22.2linux-x86_64.tar.gz Extracting cmake... The following packages will be built and installed: jansson[core]:x64-linux -> 2.13.1#2 Detecting compiler hash for triplet x64-linux... Error: while detecting compiler information: The log content at /home/abhinav/Downloads/vcpkg/buildtrees/detect_compiler/stdout-x64-linux.log is: -- Downloading https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip -> ninja-linux-1.10.2.zip... -- Configuring x64-linux-rel CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message): Command failed: /home/abhinav/Downloads/vcpkg/downloads/tools/cmake-3.22.2-linux/cmake-3.22.2-linux-x86_64/bin/cmake /home/abhinav/Downloads/vcpkg/scripts/detect_compiler -DCMAKE_MAKE_PROGRAM=/home/abhinav/Downloads/vcpkg/downloads/tools/ninja/1.10.2-linux/ninja -DCMAKE_SYSTEM_NAME=Linux -DBUILD_SHARED_LIBS=OFF -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/home/abhinav/Downloads/vcpkg/scripts/toolchains/linux.cmake -DVCPKG_TARGET_TRIPLET=x64-linux -DVCPKG_SET_CHARSET_FLAG=ON -DVCPKG_PLATFORM_TOOLSET=external -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON -DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE -DCMAKE_VERBOSE_MAKEFILE=ON -DVCPKG_APPLOCAL_DEPS=OFF -DCMAKE_TOOLCHAIN_FILE=/home/abhinav/Downloads/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON -DVCPKG_CXX_FLAGS= -DVCPKG_CXX_FLAGS_RELEASE= -DVCPKG_CXX_FLAGS_DEBUG= -DVCPKG_C_FLAGS= -DVCPKG_C_FLAGS_RELEASE= -DVCPKG_C_FLAGS_DEBUG= -DVCPKG_CRT_LINKAGE=dynamic -DVCPKG_LINKER_FLAGS= -DVCPKG_LINKER_FLAGS_RELEASE= -DVCPKG_LINKER_FLAGS_DEBUG= -DVCPKG_TARGET_ARCHITECTURE=x64 -DCMAKE_INSTALL_LIBDIR:STRING=lib -DCMAKE_INSTALL_BINDIR:STRING=bin -D_VCPKG_ROOT_DIR=/home/abhinav/Downloads/vcpkg -DZ_VCPKG_ROOT_DIR=/home/abhinav/Downloads/vcpkg -D_VCPKG_INSTALLED_DIR=/home/abhinav/Downloads/vcpkg/installed -DVCPKG_MANIFEST_INSTALL=OFF -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/abhinav/Downloads/vcpkg/packages/detect_compiler_x64-linux Working Directory: /home/abhinav/Downloads/vcpkg/buildtrees/detect_compiler/x64-linux-rel Error code: 1 See logs for more information: /home/abhinav/Downloads/vcpkg/buildtrees/detect_compiler/config-x64-linux-rel-out.log /home/abhinav/Downloads/vcpkg/buildtrees/detect_compiler/config-x64-linux-rel-err.log

    Call Stack (most recent call first): scripts/cmake/vcpkg_configure_cmake.cmake:371 (vcpkg_execute_required_process) scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake) scripts/ports.cmake:145 (include)

    Error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.

    opened by abhinaveksc 0
  • Fix strncpy compile warning

    Fix strncpy compile warning

    Original code caused compile warnings:

    /home/mstrbldr/x86/sas/Vendor/jansson/src/error.c: In function ‘jsonp_error_set_source.part.0’: /home/mstrbldr/x86/sas/Vendor/jansson/src/error.c:28:9: error: ‘__builtin_strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 28 | strncpy(error->source, source, length + 1); | ^~~~~~~ /home/mstrbldr/x86/sas/Vendor/jansson/src/error.c:26:14: note: length computed here 26 | length = strlen(source); | ^~~~~~~~~~~~~~

    opened by glezmen 0
  • Does not pass on HPE NonStop

    Does not pass on HPE NonStop

    I am building using c99 on HPE NonStop ia64 and x86. Test suite is failing as follows. Let me know what more information I can supply for diagnosis. Also, the -shared option is wrong on this platform. We need -Wshared and some LDFLAGS for export options.

    =======================================
       jansson 2.14: test/test-suite.log
    =======================================
    
    # TOTAL: 1
    # PASS:  0
    # SKIP:  0
    # XFAIL: 0
    # FAIL:  1
    # XPASS: 0
    # ERROR: 0
    
    .. contents:: :depth: 2
    
    FAIL: run-suites
    ================
    
    Suite: api
    F..................
    =================================================================
    api/check-exports
    =================================================================
    --- logs/api/check-exports/exports      2022-03-19 18:10:13 -0500
    +++ logs/api/check-exports/output       2022-03-19 18:10:13 -0500
    @@ -1,81 +0,0 @@
    -jansson_version_cmp
    -jansson_version_str
    -json_array
    -json_array_append_new
    -json_array_clear
    -json_array_extend
    -json_array_get
    -json_array_insert_new
    -json_array_remove
    -json_array_set_new
    -json_array_size
    -json_copy
    -json_deep_copy
    -json_delete
    -json_dump_callback
    -json_dump_file
    -json_dumpb
    -json_dumpf
    -json_dumpfd
    -json_dumps
    -json_equal
    -json_false
    -json_get_alloc_funcs
    -json_integer
    -json_integer_set
    -json_integer_value
    -json_load_callback
    -json_load_file
    -json_loadb
    -json_loadf
    -json_loadfd
    -json_loads
    -json_null
    -json_number_value
    -json_object
    -json_object_clear
    -json_object_del
    -json_object_deln
    -json_object_get
    -json_object_getn
    -json_object_iter
    -json_object_iter_at
    -json_object_iter_key
    -json_object_iter_key_len
    -json_object_iter_next
    -json_object_iter_set_new
    -json_object_iter_value
    -json_object_key_to_iter
    -json_object_seed
    -json_object_set_new
    -json_object_set_new_nocheck
    -json_object_setn_new
    -json_object_setn_new_nocheck
    -json_object_size
    -json_object_update
    -json_object_update_existing
    -json_object_update_missing
    -json_object_update_recursive
    -json_pack
    -json_pack_ex
    -json_real
    -json_real_set
    -json_real_value
    -json_set_alloc_funcs
    -json_sprintf
    -json_string
    -json_string_length
    -json_string_nocheck
    -json_string_set
    -json_string_set_nocheck
    -json_string_setn
    -json_string_setn_nocheck
    -json_string_value
    -json_stringn
    -json_stringn_nocheck
    -json_true
    -json_unpack
    -json_unpack_ex
    -json_vpack_ex
    -json_vsprintf
    -json_vunpack_ex
    
    =================================================================
    Suite: encoding-flags
    ............
    Suite: invalid
    ..................................................
    Suite: invalid-unicode
    ..................
    Suite: valid
    ..................................
    1 of 5 test suites failed
    FAIL run-suites (exit status: 1)
    
    opened by rsbeckerca 0
  • ld.gold: --default-symver: unknown option; ld.bfd: 1 of 5 test suites failed

    ld.gold: --default-symver: unknown option; ld.bfd: 1 of 5 test suites failed

    Dear all, I am having an issue with the latest version of Jansson (2.14) and GCC-11.2.0 on Debian Linux (bullseye). Using the ld.gold linker, which is the default in EasyBuild, the compilation crashes with --default-symver: unknown option. Switching to the ld.bfd linker it builds, but one test is failing (see attached file). So I am a bit stuck between a rock and a hard place. I should add that the previous version, which does not have the --default-symver flag, compiles without a problem. My problem might be related to issue 528. However, I should point out as I am using EasyBuild, the OS should not play too much of a role here. Any suggestions how to solve this problem? I am happy to provide more information if required. Thanks for your help!

    Jörg

    stderr.txt

    opened by sassy-crick 1
  • json_dumpb issue

    json_dumpb issue

    Hello team,

    The json library is used in our product, and the program crashed while testing.

    I think it is caused by the wrong return value of the function json_dumpb in the jansson library.

    Here are the demo and patch file for reference.

    Now let me describe the problem:

    In my opinion, json_dumpb's function is to convert json to string and put it in buf,the length is its size.

    When the length of the json serialization is greater than the length of the buf passed in, the return value is wrong. From the explanation of the api, in fact, it should return the number of bytes serialized to buf, but it's not.

    1. patch `size_t json_dumpb(const json_t *json, char *buffer, size_t size, size_t flags) { struct buffer buf = {size, 0, buffer};

      if (json_dump_callback(json, dump_to_buffer, (void *)&buf, flags)) return 0;

      return buf.used <= buf.size ? buf.used : buf.size; }`

    2. Demo ` json_t *js = json_object(); json_object_set_new(js, "test1", json_string("hello")); json_object_set_new(js, "test2", json_string("hello")); json_object_set_new(js, "test3", json_string("hello")); json_object_set_new(js, "test4", json_string("hello")); json_object_set_new(js, "test5", json_string("hello")); json_object_set_new(js, "test6", json_string("hello"));

      int n = json_dumpb(js, buf, sizeof(buf), 0); json_decref(js);

      buf[n] = '\0';

      printf("n : %s, %d\n", buf, n); return 0; `

    opened by liningjie-gift 4
Releases(v2.14)
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/

\mainpage json-c Overview and Build Status Building on Unix Prerequisites Build commands CMake options Testing Building with vcpkg Linking to libjson-

json-c 2.4k May 11, 2022
A Haskell library for fast decoding of JSON documents using the simdjson C++ library

hermes A Haskell interface over the simdjson C++ library for decoding JSON documents. Hermes, messenger of the gods, was the maternal great-grandfathe

Josh Miller 33 Apr 19, 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. 109 Apr 24, 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 4 Dec 31, 2019
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 16 May 10, 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 22 Apr 26, 2022
A small header-only library for converting data between json representation and c++ structs

Table of Contents Table of Contents What Is json_dto? What's new? v.0.3.0 v.0.2.14 v.0.2.13 v.0.2.12 v.0.2.11 v.0.2.10 v.0.2.9 v.0.2.8 v.0.2.7 v.0.2.6

Stiffstream 93 May 3, 2022
QJson is a qt-based library that maps JSON data to QVariant objects.

QJson JSON (JavaScript Object Notation) is a lightweight data-interchange format. It can represents integer, real number, string, an ordered sequence

Flavio Castelli 266 May 12, 2022
A simple class for parsing JSON data into a QVariant hierarchy and vice versa.

The qt-json project is a simple collection of functions for parsing and serializing JSON data to and from QVariant hierarchies. NOTE: Qt5 introduced a

null 294 Apr 28, 2022
A simple class for parsing JSON data into a QVariant hierarchy and vice versa.

The qt-json project is a simple collection of functions for parsing and serializing JSON data to and from QVariant hierarchies. NOTE: Qt5 introduced a

null 295 May 12, 2022
A Simple Nastran to JSON mesh reader which makes it easy to exchange data

Nastran to Json Converter A simple code that helps convert Nastran meshes to a JSON file format that is more suitable for the current day and age. Cur

Vijai Kumar S 5 Sep 23, 2021
json2cpp is compiles a json file into static constexpr data structures that can be used at compile time or runtime

json2cpp json2cpp is compiles a json file into static constexpr data structures that can be used at compile time or runtime. Features Literally 0 runt

Jason Turner 150 May 14, 2022
An easy-to-use and competitively fast JSON parsing library for C++17, forked from Bitcoin Cash Node's own UniValue library.

UniValue JSON Library for C++17 (and above) An easy-to-use and competitively fast JSON parsing library for C++17, forked from Bitcoin Cash Node's own

Calin Culianu 10 Aug 31, 2021
📟 JSON library for Arduino and embedded C++. Simple and efficient.

ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). Features JSON deserialization Optionally decodes UTF-16 escape sequences t

Benoît Blanchon 5.7k May 15, 2022
a JSON parser and printer library in C. easy to integrate with any model.

libjson - simple and efficient json parser and printer in C Introduction libjson is a simple library without any dependancies to parse and pretty prin

Vincent Hanquez 259 May 14, 2022
json_struct is a single header only C++ library for parsing JSON directly to C++ structs and vice versa

Structurize your JSON json_struct is a single header only library that parses JSON to C++ structs/classes and serializing structs/classes to JSON. It

Jørgen Lind 211 May 6, 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 127 May 12, 2022
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.3k May 9, 2022
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.3k May 6, 2022