aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2024-03-25Fix compiler warningsPetri Lehtinen1-8/+9
2024-03-25Rename a symbol to avoid collision on WindowsPetri Lehtinen1-1/+1
2024-03-25Use dtoa for double to string conversionPetri Lehtinen4-18/+6394
2024-03-08Use sprintf() to determine locale's decimal pointPetri Lehtinen2-23/+17
This should fix thread safety of encoding and decoding, since localeconv() is not tread safe after all.
2022-08-22hashtable: change to ifdefRosen Penev1-2/+2
All other usages use ifdef.
2021-11-20value, pack: use key length from json_object iternalsMaxim Zhukov2-12/+19
Reduce the number of strlen calls in the jansson backend. Test on my laptop (count of the instructions) Before: ❯ valgrind --tool=callgrind ./bin/test_object ==3105045== Events : Ir ==3105045== Collected : 441453 After: ❯ valgrind --tool=callgrind ./bin/test_object ==3144451== Events : Ir ==3144451== Collected : 440597 Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2021-09-09jansson 2.14v2.14Petri Lehtinen2-4/+4
2020-11-19Merge pull request #520 from Mephistophiles/getnPetri Lehtinen9-82/+225
Add support getn, setn functions
2020-11-06Fix hashsize() should return size_t.Kelvin Lee1-1/+1
2020-09-01reuse key len from loop check for better performanceMaxim Zhukov4-33/+62
Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-09-01introduce new fixed-size key APIMaxim Zhukov5-5/+94
This commit added functions working with fixed-size strings (non null-terminated also). It's helpful for the following cases: * getting key from substring without copying to separate buffer (better perfomance) * using pure UTF-8 keys for the objets * hack: set binary structs as the keys (see test_binary_keys) added functions: * json_object_getn * json_object_setn * json_object_setn_nocheck * json_object_setn_new * json_object_setn_new_nocheck * json_object_deln * json_object_iter_key_len added iterators: * json_object_keylen_foreach * json_object_keylen_foreach_safe Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-08-12pass length of the key to internal APIMaxim Zhukov5-54/+79
Use key length for internal API Signed-off-by: Maxim Zhukov <mussitantesmortem@gmail.com>
2020-07-02build: Add a symbol version to all exported symbols for glibcSimon McVittie1-0/+1
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). Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-05-23Handle vsnprintf corner cases.Tobias Stoeckmann1-2/+4
The function vsnprintf returns a negative value on error, e.g. on an invalid format. It's best to return NULL in such a case. Also avoid a signed integer overflow if vsnprintf returns INT_MAX. This is undefined behaviour in C and has to be avoided. A negative value is returned with a call like: json_sprintf("%111111111111111s", "", ""); INT_MAX is returned with a call like: json_sprintf("%647s%2147483000s", "", "");
2020-05-07jansson 2.13.1v2.13.12.13Petri Lehtinen2-3/+3
2020-05-06add jansson_* to shared library exportsXℹ Ruoyao1-1/+1
2020-05-05jansson 2.13v2.13Petri Lehtinen2-3/+3
2019-10-21Tweak clang-format configuration a bitPetri Lehtinen13-281/+294
Set ColumnLimit to 90, remove AllowShortCaseLabelsOnASingleLine.
2019-10-21Run clang-format on *.c, *.hPetri Lehtinen18-1494/+1165
2019-10-21Merge pull request #498 from AllenX2018/fix-issue441Petri Lehtinen1-7/+0
fix issue #441: remove strtod definition in strconv.c
2019-10-21remove undef __NO_ISOCEXT for strtod compatiblitywillson-chen1-3/+0
2019-10-17Merge branch 'master' into fix-issue281Petri Lehtinen7-28/+86
2019-10-17Merge pull request #505 from AllenX2018/recursive_object_updatePetri Lehtinen3-3/+61
Recursive object update
2019-10-17Merge pull request #501 from AllenX2018/fix-issue481Petri Lehtinen4-24/+24
fix issue #481
2019-10-12add loop check for json_object_update_recursive functionallen1-7/+43
2019-10-11Add json_object_update_recursive()Henrique Cabral3-0/+22
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.
2019-10-09fix issue #481allen4-24/+24
2019-10-08fix issue #281allen1-0/+24
2019-10-08fix issue #441AllenX20181-4/+0
It already has "strtod" function in stdlib.h and because __USE_MINGW_ANSI_STDIO is desperated
2019-09-23Merge pull request #494 from luzpaz/typosPetri Lehtinen1-1/+1
Fix various typos
2019-09-20Fix various typosluz.paz1-1/+1
Found via `codespell -q 2` (v1.17.0.dev0)
2019-09-16add the loop key length macro for circular reference detectallen3-5/+6
2019-08-12add loop check in json deep copy #457allen3-17/+56
2019-03-12Add runtime version checking functionsSean Bright4-1/+41
This patch adds two new exported functions: * `jansson_version_str` - Returns a human-readable version number * `jansson_version_cmp` - Returns an integer less than, equal to, or greater than zero if the runtime version of Jansson is found, respectively, to be less than, to match, or be greater than the provided major, minor, and micro.
2018-11-25jansson 2.12Corey Farrell2-3/+3
2018-11-05Remove inappropriate jsonp_free which caused segmentation fault.Corey Farrell1-7/+2
pack_string should never free str on error. This wouldn't be a problem except the check for `ours` was inverted. Just remove the check for ours since the true condition is unreachable. json_vpack_ex also had an error check for s.has_error. This can never be true unless value is NULL. Expand pack_unpack testing to cover empty format string, NULL object value with non-null concatenated key, array containing a non-null object after a NULL (error) string. Fixes #444
2018-10-17Merge pull request #436 from edgale/warningsCorey Farrell3-6/+2
removed various warnings
2018-10-15fixed extra bracketMaximilian Röhrle1-1/+1
2018-10-15removed explicit castsMaximilian Röhrle2-6/+6
2018-09-25More work on json_pack error reporting.Corey Farrell1-5/+41
* Remove errant line-feed from pack_object error message. * Correct error message in pack_object_inter. * Create pack_integer / pack_real to get the correct error messages on failure when packing numeric values. * Add tests for packing NAN and infinity directly, in an array and as an object value.
2018-09-25json_pack: Improve handling of formats with '?' and '*'.Corey Farrell1-27/+47
When NULL is received for an optional argument we should not set an error message as this would block later error messages. If NULL is received for a non-optional string we should set has_error. Set has_error for UTF-8 errors to ensure optional strings with UTF-8 errors are not replaced with json_null(). Use 'purpose' argument in NULL error messages of read_string. Add error handling and tests for invalid formats where '+', '#', or '%' is used on an optional string 's?' or 's*'. Fix NULL string error messages to use 'purpose'. Refactor skipping of '*' token, this is now handled by read_string and pack_object_inter. This allows invalid format strings such as 's*#' and 's*+' to produce error messages. Fixes #437
2018-08-31removed various warningsMaximilian Röhrle4-12/+8
2018-08-30This fixes https://github.com/akheron/jansson/issues/434Maximilian Röhrle2-2/+2
2018-08-12Rename a varialble that shadows another onePetri Lehtinen1-4/+4
Fixes #430
2018-08-09Enable -Bsymbolic-functions linker flag whenever possibleMichal Privoznik1-1/+2
It was discovered fairly recently that JSON parsing libraries use common pattern to name their exported symbols (they all use json_ prefix). So eventually it happens that two symbols from two different libraries have the same name. This will lead to cryptic crashes (see [1] and [2]). Linking with -Bsymbolic-functions prevents this. 1: https://gitlab.gnome.org/GNOME/json-glib/issues/33 2: https://groups.google.com/forum/#!topic/jansson-users/7Efx-RI45IU Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-08-02Merge pull request #423 from coreyfarrell/gcc-8Petri Lehtinen1-1/+1
Deal with warnings under gcc 8.
2018-07-25Call va_end after va_copy in json_vsprintfXin Long1-5/+12
As said in man doc: "Each invocation of va_copy() must be matched by a corresponding invocation of va_end() in the same function." va_copy may alloc memory in some system, it's necessay to free it by va_end. Fixes: efe6c7b3f2b3 ("Add json_sprintf and json_vsprintf") Signed-off-by: Xin Long <lucien.xin@gmail.com>
2018-07-14Deal with warnings under gcc 8.Corey Farrell1-1/+1
Recent versions of gcc have introduced compiler warnings for string operations that could be truncated. This caused problems with -Werror. src/error.c used strncpy to write "..." to a string, but skipped writing the NUL terminator. Switch this to use memcpy. src/load.c produced warnings from snprintf writing error strings that could be truncated. Added code to autotools build to detect `-Wno-format-truncation', add it to AM_CFLAGS if supported.
2018-07-09Avoid invalid memory read in json_pack()Petri Lehtinen1-1/+4
Initial patch by @bharjoc-bitdefender Fixes #421
2018-03-22Fix error handling in json_packMaxim Zhukov1-32/+32
Fixed a bug where the error message was not filled if an empty object was passed to the json_pack. Fixes #271