json-c v0.13 Release Notes

Release Date: 2017-11-29 // about 4 years ago
  • ๐Ÿš€ This release, being three and a half years after the 0.12 branch (f84d9c), has quite a number of changes included. The following is a sampling of the most significant ones.

    ๐Ÿš€ Since the 0.12 release, 250 issues and pull requests have been closed. See issues_closed_for_0.13.md for a complete list.

    ๐Ÿšš Deprecated and removed features:

    • ๐Ÿšš All internal use of bits.h has been eliminated. The file will be removed. Do not use: hexdigit(), error_ptr(), error_descrition() and it_error()
    • ๐Ÿšš lh_abort() is deprecated. It will be removed.

    Behavior changes:

    • ๐Ÿšฉ Tighten the number parsing algorithm to raise errors instead of truncating the results. For example 12.3.4 or 2015-01-15, which now return null. See commit 99d8fc

    • Use size_t for array length and size. Platforms where sizeof(size_t) != sizeof(int) may not be backwards compatible See commits 45c56b, 92e9a5 and others.

    • Check for failue when allocating memory, returning NULL and errno=ENOMEM. See commit 2149a04.

    • Change json_object_object_add() return type from void to int, and will return -1 on failures, instead of exiting. (Note: this is not an ABI change)

    ๐Ÿ†• New features:

    • We're aiming to follow RFC 7159 now.

    • Add a couple of additional option to json_object_to_json_string_ext: JSON_C_TO_STRING_PRETTY_TAB JSON_C_TO_STRING_NOSLASHESCAPE

    • Add a json_object_object_add_ex() function to allow for performance improvements when certain constraints are known to be true.

    • ๐Ÿ”ง Make serialization format of doubles configurable, in two different ways: Call json_object_set_serializer with json_object_double_to_json_string and a custom format on each double object, or Call json_c_set_serialization_double_format() to set a global or thread-wide format.

    • Add utility function for comparing json_objects - json_object_equal()

    • Add a way to copy entire object trees: json_object_deep_copy()

    • Add json_object_set_ function to modify the value of existing json_object's without the need to recreate them. Also add a json_object_int_inc function to adjust an int's value.

    • โž• Add support for JSON pointer, RFC 6901. See json_pointer.h

    • Add a json_util_get_last_err() function to retrieve the string describing the cause of errors, instead of printing to stderr.

    • Add perllike hash function for strings, and json_global_set_string_hash() 8f8d03d

    • Add a json_c_visit() function to provide a way to iterate over a tree of json-c objects.

    ๐Ÿ›  Notable bug fixes and other improvements:

    • ๐Ÿ‘‰ Make reference increment and decrement atomic to allow passing json objects between threads.
    • Fix json_object_object_foreach to avoid uninitialized variable warnings.
    • ๐Ÿ‘Œ Improve performance by removing unneeded data items from hashtable code and reducing duplicate hash computation.
    • ๐Ÿ‘Œ Improve performance by storing small strings inside json_object
    • Improve performance of json_object_to_json_string by removing variadic printf. commit 9ff0f49
    • ๐Ÿ“œ Issue #371: fix parsing of "-Infinity", and avoid needlessly copying the input when doing so.
    • Fix stack buffer overflow in json_object_double_to_json_string_format() - commit 2c2deb87
    • ๐Ÿ›  Fix various potential null ptr deref and int32 overflows
    • Issue #332: fix a long-standing bug in array_list_put_idx() where it would attempt to free previously free'd entries due to not checking the current array length.
    • ๐Ÿ‘ Issue #195: use uselocale() instead of setlocale() in json_tokener to behave better in threaded environments.
    • Issue #275: fix out of bounds read when handling unicode surrogate pairs.
    • Ensure doubles that happen to be a whole number are emitted with ".0" - commit ca7a19
    • ๐Ÿ–จ PR#331: for Visual Studio, use a snprintf/vsnprintf wrapper that ensures the string is terminated.
    • Fix double to int cast overflow in json_object_get_int64.
    • Clamp double to int32 when narrowing in json_object_get_int.
    • ๐Ÿ“œ Use strtoll() to parse ints - instead of sscanf
    • โš  Miscellaneous smaller changes, including removing unused variables, fixing warning about uninitialized variables adding const qualifiers, reformatting code, etc...

    ๐Ÿ— Build changes:

    • โž• Add Appveyor and Travis build support
    • ๐Ÿ Switch to using CMake when building on Windows with Visual Studio. A dynamic .dll is generated instead of a .lib config.h is now generated, config.h.win32 should no longer be manually copied
    • โž• Add support for MacOS through CMake too.
    • ๐Ÿ— Enable silent build by default
    • ๐Ÿ”— Link against libm when needed
    • โž• Add support for building with AddressSanitizer
    • โž• Add support for building with Clang
    • ๐Ÿ”€ Add a --enable-threading configure option, and only use the (slower) sync_add_and_fetch()/sync_sub_and_fetch() function when it is specified.

    List of new functions added:


    • array_list_bsearch()
    • array_list_del_idx()
    • json_object_to_json_string_length()
    • json_object_get_userdata()
    • json_object_set_userdata()
    • json_object_object_add_ex()
    • json_object_array_bsearch()
    • json_object_array_del_idx()
    • json_object_set_boolean()
    • json_object_set_int()
    • json_object_int_inc()
    • json_object_set_int64()
    • json_c_set_serialization_double_format()
    • json_object_double_to_json_string()
    • json_object_set_double()
    • json_object_set_string()
    • json_object_set_string_len()
    • json_object_equal()
    • json_object_deep_copy()


    • json_pointer_get()
    • json_pointer_getf()
    • json_pointer_set()
    • json_pointer_setf()


    • json_object_from_fd()
    • json_object_to_fd()
    • json_util_get_last_err()


    • json_c_visit()

    ๐Ÿ”— linkhash.h

    • json_global_set_string_hash()
    • lh_table_resize()

    ๐Ÿ–จ printbuf.h

    • ๐Ÿ–จ printbuf_strappend()