summaryrefslogtreecommitdiff
path: root/json_object.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Apply gcc's "const" attribute to the json_c_object_sizeof() function as an ↵Eric Haszlakiewicz2017-12-121-1/+1
| | | | optimizer hint. Also, rename that function from json_object_sizeof().
* json_object: Add size_t json_object_sizeof()Björn Esser2017-12-111-0/+5
|
* Make sure to include the "*" on function pointer arguments to avoid a ↵Eric Haszlakiewicz2017-12-041-1/+1
| | | | warnings from VS2015. See also PR#384.
* Update json_object.cssrlive2017-12-041-2/+2
|
* In json_object_deep_copy(), copy over _userdata, at least for ↵Eric Haszlakiewicz2017-11-291-59/+122
| | | | json_type_string's with the default serializer set, and provide a way for people using custom serializers to provide a custom shallow_copy method.
* Rename _set_last_err() to _json_c_set_last_err().Eric Haszlakiewicz2017-11-291-2/+2
|
* Merge branch 'json_deep_copy' of https://github.com/commodo/json-c into ↵Eric Haszlakiewicz2017-11-291-0/+103
|\ | | | | | | commodo-json_deep_copy
| * json_object: implement json_object_deep_copy()Alexandru Ardelean2017-11-271-0/+103
| | | | | | | | | | | | | | | | Because doing `json_tokener_parse(json_object_get_string(src))` feels sloppy, dirty, and makes me want to cry at night sometimes. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Rename json_object_add_int() to json_object_int_inc() and eliminate the ↵Eric Haszlakiewicz2017-11-271-15/+1
|/ | | | "int64" variant since we store 64-bit values internally anyway.
* Add json_object_add_int functionsJuraj Vijtiuk2017-09-141-0/+26
|
* Fix double to int cast overflow in json_object_get_int64.Kurt Schwehr2017-09-111-0/+4
| | | | Found with autofuzz in GDAL
* Add long long 64-bit checkJason King2017-09-081-0/+4
|
* rollback api to 0.12Haffon2017-09-071-7/+7
|
* Merge pull request #2 from json-c/masterHaffon2017-09-071-18/+30
|\ | | | | merge upstream
| * Undo a bit of 2d1da5ab: handle per-thread formats for double serialization, ↵Eric Haszlakiewicz2017-09-051-4/+4
| | | | | | | | even if --enable-threading wasn't specified.
| * Add a --enable-threading configure option, and only use the (slower) ↵Eric Haszlakiewicz2017-09-031-6/+6
| | | | | | | | __sync_add_and_fetch()/__sync_sub_and_fetch() function when it is specified.
| * Explicitly check for GCC's atomic functions instead of depending on the ↵Eric Haszlakiewicz2017-09-021-2/+8
| | | | | | | | | | | | __GNUC__ define. Add a comment mentioning the limitation even though the _ref_count value is hanled atomically.
| * Merge branch 'pull-211'Eric Haszlakiewicz2017-09-021-14/+20
| |\ | | | | | | | | | This is EmielBruijntes' "Atomic updates for the refcount"
| | * subtract first, then retrieve valueEmiel Bruijntjes2015-11-281-1/+1
| | |
| | * added tabs instead of spaces to be compatible with rest of codeEmiel Bruijntjes2015-11-271-8/+8
| | |
| | * update indentationEmiel Bruijntjes2015-11-271-0/+2
| | |
| | * reference increment and decrement is now atomic (when using a GCC compatible ↵Emiel Bruijntjes2015-11-271-14/+18
| | | | | | | | | | | | compiler), which allows passing json objects between threads
* | | Merge pull request #1 from json-c/masterHaffon2017-08-301-7/+5
|\ \ \ | |/ / | | | want to merge the original repository
| * | PR#331: for Visual Studio, use a snprintf/vsnprintf wrapper that ensures the ↵Eric Haszlakiewicz2017-08-251-7/+1
| | | | | | | | | | | | string is terminated.
| * | Clamp double to int32 when narrowing in json_object_get_int.Kurt Schwehr2017-08-081-0/+4
| | | | | | | | | | | | Avoids undefined behavior. Found by autofuzz.
* | | 1.make it can been compiled with Visual Studio 2010Haffon2017-08-221-12/+15
|/ / | | | | | | | | 2.replace json_object_get/put API with json_object_retain/release, as they operate the reference counter, and confused with array_list_get/put_idx. 3.replace array_list_get/put_idx API with array_list_get/insert to make them more clear to use.
* | build: make `strerror()` override-ableAlexandru Ardelean2017-07-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we want to override `strerror()` in libjson-c to make tests consistent across platforms, we need to do it build-wide as configure/build option. Apple linkers make it really hard to override functions at link-time, and this seems to be locked down on travis-ci.org [ for security reasons I assume ]. While I got it to work locally, it did not work when running on travis. Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Move a variable declaration to the start of the block to work better with ↵Eric Haszlakiewicz2017-07-091-1/+1
| | | | | | | | older compilers.
* | Add extra casts to void * to squash some warning on certain systems (e.g. ↵Eric Haszlakiewicz2017-07-091-3/+3
| | | | | | | | CentOS w/ gcc 4.1.2).
* | Fix bad usage of strncat introduces in 1a94c70. Pointed out by @rouault in ↵Eric Haszlakiewicz2017-07-091-4/+3
| | | | | | | | PR #331.
* | Eliminate static qualifiers on a couple local variables that were causing ↵Eric Haszlakiewicz2017-07-091-2/+2
| | | | | | | | thread safety issues. Suggested by @rouault in PR #331.
* | Reformat json_object_double_to_json_string_format() to have consistent spacing.Eric Haszlakiewicz2017-07-081-30/+34
| |
* | Add a json_c_set_serialization_double_format() function to set the ↵Eric Haszlakiewicz2017-06-181-9/+76
| | | | | | | | *library-wide* format for how doubles are written to a serialized JSON output.
* | Fix stack buffer overflow in json_object_double_to_json_string_format()Even Rouault2017-05-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue originally found in the json-c 0.11 internal copy in GDAL but also found in latest git version. If doing things like json_object* obj = json_object_new_double(1e300); json_object_set_serializer(obj, json_object_double_to_json_string, "%f", NULL); json_object_to_json_string(obj) size = snprintf(buf, sizeof(buf), format ? format : (modf(jso->o.c_double, &dummy) == 0) ? "%.17g.0" : "%.17g", jso->o.c_double); will return a value greater than 128 since at least 300 characters are needed. This value is then passed to printbuf_memappend(pb, buf, size); that tries to read size bytes in buf. So we should clamp size to sizeof(buf). And on Windows, _snprintf() returns -1 in that situation, so deal also with this case. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1682 Credit to OSS-Fuzz
* | Fix error C3688 when compiling on Visual Studio 2015: invalid literal suffix ↵Jason Li2017-03-241-1/+1
| | | | | | | | 'PRId64'; literal operator or literal operator template 'operator ""PRId64' not found
* | Add FALLTHRU comment to handle GCC7 warnings.marxin2017-03-211-0/+1
| |
* | Restore sprintbuf(), add macro for string literalsQuentin Young2017-02-041-31/+30
| | | | | | | | | | | | | | | | | | | | Hawciz pointed out that the previous commit modifies the public interface of printbuf. Per his suggestion, sprintbuf() was restored and a new pair of macros was added that wraps printbuf_memappend(). Using a wrapper macro instead of modifying sprintbuf() also reduces function call overhead, bringing total performance gains to approximately 400%.
* | Improve json_object -> string performanceQuentin Young2017-02-021-4/+11
| | | | | | | | Removes variadic prints for ~3x performance improvement.
* | bugfix: floating point representaion without fractional partJan Gerhards2016-11-271-1/+4
| | | | | | | | closes https://github.com/json-c/json-c/issues/278
* | strdup_compat.h: re-spin this compat header ; use math_compat.h as templateAlexandru Ardelean2016-11-221-7/+1
| | | | | | | | Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Revert "compat/strdup.h: move common compat check for strdup() to own file"Emmanuele Bassi2016-11-071-1/+7
| | | | | | | | | | | | | | | | | | | | This reverts commit aaba8c1080533133329086e47f4f45981dfdd1ee. This commit breaks builddir != srcdir build, but, more importantly, it also adds a dependency on a header, "config.h", which is not installed and it's supposed to be private — since it's generated at configuration time and it's not meant to be used by projects compiling against a library.
* | compat/strdup.h: move common compat check for strdup() to own fileAlexandru Ardelean2016-11-031-7/+1
| | | | | | | | Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
* | Handle NULL objects in json_object_get_userdata() by returning NULL, but ↵Eric Haszlakiewicz2016-10-291-1/+4
| | | | | | | | abort in json_object_set_userdata() since we can't actually do anything with the userdata.
* | Issue #280: add a few assert() calls to ensure objects are of the ↵Eric Haszlakiewicz2016-10-291-4/+19
| | | | | | | | appropriate type.
* | Merge pull request #277 from ALLTERCO/json_object_set_xxxEric Haszlakiewicz2016-10-081-1/+49
|\ \ | | | | | | Json object set xxx
| * | try restore windows automated buildsStoian Ivanov2016-10-071-1/+1
| | |
| * | fix compiler warning for int sizesStoian Ivanov2016-10-071-1/+1
| | |
| * | string set and testsStoian Ivanov2016-10-071-0/+21
| | |
| * | some basic setStoian Ivanov2016-10-051-3/+23
| | |
| * | json_object_set_boolean for upstream style checkStoian Ivanov2016-09-211-0/+7
| | |