Commit Graph

106 Commits

Author SHA1 Message Date
Jan Gerhards
ca7a1973e2 bugfix: floating point representaion without fractional part
closes https://github.com/json-c/json-c/issues/278
2016-11-27 11:47:00 +01:00
Alexandru Ardelean
8cb86a583a strdup_compat.h: re-spin this compat header ; use math_compat.h as template
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-22 16:37:29 +02:00
Emmanuele Bassi
7601f20d70 Revert "compat/strdup.h: move common compat check for strdup() to own file"
This reverts commit aaba8c1080.

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.
2016-11-07 20:51:11 +00:00
Alexandru Ardelean
aaba8c1080 compat/strdup.h: move common compat check for strdup() to own file
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2016-11-03 15:51:33 +02:00
Eric Haszlakiewicz
d4899bd4d5 Handle NULL objects in json_object_get_userdata() by returning NULL, but abort in json_object_set_userdata() since we can't actually do anything with the userdata. 2016-10-29 15:42:36 -04:00
Eric Haszlakiewicz
f8132f932d Issue #280: add a few assert() calls to ensure objects are of the appropriate type. 2016-10-29 15:31:31 -04:00
Eric Haszlakiewicz
818156f6f7 Merge pull request #277 from ALLTERCO/json_object_set_xxx
Json object set xxx
2016-10-08 12:08:53 -04:00
Stoian Ivanov
be63ba99ca try restore windows automated builds 2016-10-07 22:54:06 +03:00
Stoian Ivanov
a26305d428 fix compiler warning for int sizes 2016-10-07 01:07:34 +03:00
Stoian Ivanov
e518b22b72 string set and tests 2016-10-07 00:51:24 +03:00
Stoian Ivanov
05f025c075 some basic set 2016-10-05 23:55:46 +03:00
Alexey Konovalov
b2fbf93df0 fixed wrong object name in json_object_all_values_equal 2016-09-27 11:20:49 +03:00
Stoian Ivanov
fae09456ae json_object_set_boolean for upstream style check 2016-09-21 01:31:00 +03:00
Eric Haszlakiewicz
5fccfed4f4 Issue #260: add a check to prevent trivial loops in the object tree, even though it is up to the callers to avoid doing so in more complex cases. 2016-08-20 22:42:59 -04:00
Eric Haszlakiewicz
c4d060bf80 json_object_object_add_ex() should have shared code with json_object_object_add(), and been changed to return int at the same time the latter was. Do that now.
Also correct a couple of calls to _to_json_string to check the return value.
2016-08-20 22:42:59 -04:00
Eric Haszlakiewicz
4d62de3898 Revert bogus change to json_object_get() made in f40b08d8 that caused it to always return NULL. (Issue #259)
Also undo NULL check in json_tokener_set_flags(): it's not at all valid toi
 try to set flags on a NULL pointer, and doing so should not be silently
 ignored.
2016-08-11 17:05:41 -04:00
Eric Haszlakiewicz
0ad87649d4 Merge pull request #255 from RyDroid/minor-c2
Minor changes in C source code
2016-08-10 15:06:30 -04:00
Nicola Spanti (RyDroid)
f40b08d8f0 Minor changes in C source code 2016-08-08 15:20:41 +02:00
jobol
344009bf26 Add method 'json_object_to_json_string_length'
This new method allows to also
get the length of the generated string.

Fix #165

Change-Id: Iea91404027f143ca3d29a4c58d7c07ae53556110
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
2016-07-27 14:45:25 +02:00
Eric Haszlakiewicz
595891729e Issue #236: Add -Wcast-qual and fix casts to retain constness.
To better distinguish between entry->k and entry->v being const within linkhash, but non-const outside, add lh_entry_v() and lh_entry_k() accessors.
Make lh_entry->k const.
2016-06-11 18:19:39 +00:00
Matthias Schiffer
f87e378d48 Add public API to get and set userdata
Also, json_object_set_serializer is changed to respect the userdata
and user_delete parameters when to_string_func is NULL.
2016-05-29 11:24:55 +02:00
Matthias Schiffer
c2b004ba0e Make default double serializer ignore userdata again
The user might want to use the userdata for something different, so the
serializer should ignore it by default.

Explicitly setting the serializer to json_object_double_to_json_string will
still make it interpret the userdata as a format string.
2016-05-29 11:24:55 +02:00
Eric Haszlakiewicz
996be85843 Fix a few places that needed adjustment for the size_t changes, including updating the range checks to use a calculated SIZE_T_MAX. 2016-05-23 02:10:58 +00:00
Eric Haszlakiewicz
9a2915ce66 Merge branch 'fixes-for-upstream' of https://github.com/doctaweeks/json-c into doctaweeks-fixes-for-upstream 2016-05-23 02:08:28 +00:00
Jan-Philipp Litza
21dc5dc92b Export json_object_double_to_json_string() and use custom format string 2016-05-06 16:12:44 +02:00
Eric Haszlakiewicz
1fb87cd196 Merge branch 'master' of https://github.com/Protovision/json-c into Protovision-master 2016-04-30 18:52:47 +00:00
Eric Haszlakiewicz
82bdbdba24 Merge pull request #219 from rouault/low_heap_robustness_fixes
Fix various potential null ptr deref and int32 overflows
2016-04-30 14:44:05 -04:00
Eric Haszlakiewicz
4e0c8b55fb Merge pull request #220 from hschaa/master
Add utility function for comparing json_objects
2016-04-30 14:42:16 -04:00
chenha0
dffdee966f Fix issue #221: JSON_C_TO_STRING_NOSLASHESCAPE works incorrectly
Tests added.
2016-01-21 20:12:48 +08:00
Helmut Schaa
00e475c434 Add utility function for comparing json_objects 2016-01-13 15:56:38 +01:00
Even Rouault
77a4276a8c Fix various potential null ptr deref and int32 overflows
This fix errors that can happen when ingesting very large JSON files
when hitting the maximum heap size of the process.
2016-01-11 12:15:54 +01:00
Eric Haszlakiewicz
537f8bcbdb Add const qualifiers to several functions that don't modify the json_object. 2015-12-26 21:42:18 +00:00
Eric Haszlakiewicz
980cdd61be Merge commit '2be921d88376e78f84d79aafa6db2714da804e59' 2015-12-08 20:51:06 -06:00
Eric Haszlakiewicz
316da85818 Fix issue #201: add a JSON_C_TO_STRING_NOSLASHESCAPE flag to turn off escaping of forward slashes. 2015-11-28 20:00:30 -06:00
Daniel M. Weeks
92e9a5032b Use size_t for json object array ops 2015-11-24 14:00:32 -05:00
James Myatt
3f012eb0f8 Fix build in Visual Studio 2015-10-09 23:24:55 +01:00
Eric Haszlakiewicz
12916e229c Merge pull request #196 from rgerhards/improve-performance
Performance improvements
2015-09-28 22:25:29 -04:00
Rainer Gerhards
c4f8cc34df more efficient handling for smalls strings inside json_object
smalls strings inside json_objects had a high overhead because dynamic
memory allocation was needed for each of them. This also meant that the
pointer needed to be updated. This is now changed so that small strings
can directly be stored inside the json_object. Note that on the regular
64 bit machines a pointer takes 8 bytes. So even without increasing
memory, we could store string up to 7 bytes directly inside the object.
The max size is configurable. I have selected up to 31 bytes (which
means a buffer of 32 including the NUL byte). This brings a 24-bytes
memory overhead, but I consider that still useful because the memory
allocator usually also has quite some overhead (16 bytes) for
dyn alloced memory blocks. In any case, the max buffer size can be
tweaked via #define.
2015-09-23 15:56:48 +02:00
Rainer Gerhards
1ae4b50bde remove unneeded data items from hashtable code
These items were used for statistics tracking, but no code at all
exists to consume them. By removing them we save

a) space
   because they counters required space, and did so in each and every
   json object

b) performance
   because calloc() needs to write less data and the counters are
   no longer maintained; cache performance can be better, load
   on OS main memory is lighter

We could conditionally enable/disable these counters, but I have not
done this they were really nowhere used and it looked more like a
left-over from the import of hashtable code.
2015-09-23 12:40:57 +02:00
Rainer Gerhards
2d549662be add json_object_object_add_ex() API
This provides more control over some detail aspects, many
of which are performance related.
2015-09-23 09:43:00 +02:00
Rainer Gerhards
d8e44dc685 reduce duplicate hash computation in json_object_object_add()
This can be a very considerable performance saver.
2015-09-22 19:07:30 +02:00
Eric Haszlakiewicz
b594c34f57 Merge pull request #174 from haata/master
Adding JSON_C_TO_STRING_PRETTY_TAB flag
2015-05-31 12:10:13 -07:00
Jacob Alexander
92d4cf15f0 Adding JSON_C_TO_STRING_PRETTY_TAB flag
- Tabs are easier to read for tired eyes and editor adjustable
2015-05-27 17:37:39 -07:00
Mark Swoope
cdca9d3c8e Added array_list_del_idx and json_object_array_del_idx 2015-04-02 14:05:27 -07:00
James Myatt
18b3c49296 Use more appropriate casts 2015-03-04 10:45:37 +00:00
Eric Haszlakiewicz
484ca368f0 Slight style tweaks to the bsearch changest. 2015-03-04 03:10:10 +00:00
Alexander Dahl
2f5789bdef add bsearch for arrays
Arrays can already be sorted with json_object_array_sort() which uses
qsort() of the standard C library. This adds a counterpart using the
bsearch() from C.
2014-08-21 15:42:50 +02:00
Eric Haszlakiewicz
2149a04ca8 Check for failures when allocating memory; return NULL and set errno=ENOMEM in a few of those cases.
Thanks to Susant Sahani for pointing out some of these.
2014-04-19 20:33:05 -04:00
Eric Haszlakiewicz
92a7740e90 Reformat some code in json_object.c 2014-04-19 20:23:54 -04:00
Eric Haszlakiewicz
e6f1322b5e Issue#114: check for the presence of isnan and isinf, and provide compat macros on MSCV where _isnan and _finite exist instead. 2014-03-02 12:16:37 -05:00