Eric Haszlakiewicz
82bdbdba24
Merge pull request #219 from rouault/low_heap_robustness_fixes
Fix various potential null ptr deref and int32 overflows
9 years ago
Eric Haszlakiewicz
4e0c8b55fb
Merge pull request #220 from hschaa/master
Add utility function for comparing json_objects
9 years ago
chenha0
dffdee966f
Fix issue #221 : JSON_C_TO_STRING_NOSLASHESCAPE works incorrectly
Tests added.
9 years ago
Helmut Schaa
00e475c434
Add utility function for comparing json_objects
9 years ago
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.
9 years ago
Eric Haszlakiewicz
537f8bcbdb
Add const qualifiers to several functions that don't modify the json_object.
9 years ago
Eric Haszlakiewicz
980cdd61be
Merge commit '2be921d88376e78f84d79aafa6db2714da804e59'
9 years ago
Eric Haszlakiewicz
316da85818
Fix issue #201 : add a JSON_C_TO_STRING_NOSLASHESCAPE flag to turn off escaping of forward slashes.
9 years ago
Emiel Bruijntjes
7e98ed93f4
subtract first, then retrieve value
9 years ago
Emiel Bruijntjes
9d85367679
added tabs instead of spaces to be compatible with rest of code
9 years ago
Emiel Bruijntjes
827f0fd8ef
update indentation
9 years ago
Emiel Bruijntjes
23ee243113
reference increment and decrement is now atomic (when using a GCC compatible compiler), which allows passing json objects between threads
9 years ago
Daniel M. Weeks
92e9a5032b
Use size_t for json object array ops
11 years ago
James Myatt
3f012eb0f8
Fix build in Visual Studio
10 years ago
Eric Haszlakiewicz
12916e229c
Merge pull request #196 from rgerhards/improve-performance
Performance improvements
10 years ago
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.
10 years ago
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.
10 years ago
Rainer Gerhards
2d549662be
add json_object_object_add_ex() API
This provides more control over some detail aspects, many
of which are performance related.
10 years ago
Rainer Gerhards
d8e44dc685
reduce duplicate hash computation in json_object_object_add()
This can be a very considerable performance saver.
10 years ago
Eric Haszlakiewicz
b594c34f57
Merge pull request #174 from haata/master
Adding JSON_C_TO_STRING_PRETTY_TAB flag
10 years ago
Jacob Alexander
92d4cf15f0
Adding JSON_C_TO_STRING_PRETTY_TAB flag
- Tabs are easier to read for tired eyes and editor adjustable
10 years ago
Mark Swoope
cdca9d3c8e
Added array_list_del_idx and json_object_array_del_idx
10 years ago
James Myatt
18b3c49296
Use more appropriate casts
10 years ago
Eric Haszlakiewicz
484ca368f0
Slight style tweaks to the bsearch changest.
10 years ago
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.
11 years ago
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.
11 years ago
Eric Haszlakiewicz
92a7740e90
Reformat some code in json_object.c
11 years ago
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.
11 years ago
Keith Derrick
c51b88d69a
Avoid potential overflow in json_object_get_double
sscanf is always a potential problem when converting numeric
values as it does not correctly handle over- and underflow
(or at least gives no indication that it has done so).
This change converts json_object_get_double() to use strtod()
according to CERT guidelines.
12 years ago
Eric Haszlakiewicz
06450206c4
Issue #59 : change the floating point output format to %.17g so values with more than 6 digits show up in the output.
12 years ago
Eric Haszlakiewicz
a23caf677c
Use sizeof instead of hard coded values when calling snprintf.
12 years ago
Eric Haszlakiewicz
51993c28c2
Added a json_object_new_double_s() convenience function to allow an exact string representation of a double to be specified when creating the object and use it in json_tokener_parse_ex() so a re-serialized object more exactly matches the input.
Add json_object_free_userdata() and json_object_userdata_to_json_string() too.
12 years ago
Eric Haszlakiewicz
ef43fe3571
Merge pull request #96 from rouault/remove_strdnup
Remove redefinition of strndup() which is no longer used in the codebase
12 years ago
Even Rouault
1a957c2edc
Remove redefinition of strndup() which is no longer used in the codebase
12 years ago
Taneli Mielikainen
c5523a17e8
fixing problem that isinf(-Inf) can be 1 or -1
12 years ago
Eric Haszlakiewicz
98a62a7652
Merge pull request #89 from ayanes/master
Support NaN and Infinity
12 years ago
Adrian Yanes
d086e2018c
Fixes for Infinity and NaN
Although JSON RFC does not support NaN or Infinity
as numeric values ECMA 262 section 9.8.1 defines
how to handle these cases as strings
12 years ago
Anatol Belski
ed819fb926
snprintf definition is needed here, too
12 years ago
Eric Haszlakiewicz
5b36a432c8
Merge branch 'remicollet-issue-float'
Conflicts:
json_util.c
12 years ago
Greg Hazel
cca74c6de6
add json_object_object_length
12 years ago
Alexander Klauer
2be921d883
Fixed json_object_object_add().
* Return value of json_object_object_add() changed from void to int.
Return value now indicates success or failure.
* Check whether allocations are successful.
* Do not exit program from within the library.
12 years ago
Abioy
7eaa849e9a
escape '\f' in json_escape_str
'\f' is a llegal char and should be escape in printbuf
12 years ago
Remi Collet
32d149c8f6
probably worth an option for this
12 years ago
Remi Collet
8c847968c7
Save space, drop unuseful trailing zeroes
12 years ago
Remi Collet
4014fe86d9
Simple fix to double encode
12 years ago
Eric Haszlakiewicz
4e4af93d66
Fix issue #53 - ensure explicit length string are still NUL terminated, and fix json_tokener_parse() to work properly with embedded unicode \u0000 values in strings.
Adjust test_null to check for this case.
See also http://bugs.debian.org/687269
12 years ago
Eric Haszlakiewicz
e36e562872
Reformat json_object_object_get() and json_object_object_get_ex().
13 years ago
Eric Haszlakiewicz
5450bed051
Fix json_object_object_get() so it returns NULL if the incoming json_object is NULL.
13 years ago
Eric Haszlakiewicz
5f4739e2eb
Change json_object_put to return 1 if the object passed was actually freed. (or 0 if only the reference count was decremented)
13 years ago
Eric Haszlakiewicz
38f421a2e7
Add a json_set_serializer() function to allow the string output of a json_object to be customized.
13 years ago