Commit Graph

71 Commits

Author SHA1 Message Date
Michael Chen 4d9524e54c Added is_modified feature to json_t struct
Added is_modified field to json_t struct along with getter and setter
methods.
2015-07-06 11:40:13 -04:00
Karl Lew 571617ebfc use __sun instead of sun 2014-04-08 15:57:58 +00:00
Karl Lew 33e4988180 SmartOS build fix 2014-04-06 04:28:52 +00:00
Petri Lehtinen 17ec22f514 Merge branch '2.6' 2014-02-11 14:49:15 +02:00
Petri Lehtinen 8f80c2d838 CVE-2013-6401: Change hash function, randomize hashes
Thanks to Florian Weimer and Eric Sesterhenn for reporting, reviewing
and testing.
2014-02-11 08:41:30 +02:00
Petri Lehtinen 30fdf6067e Update copyrights for 2014 2014-01-28 09:16:05 +02:00
nmlgc 98610bfcec Check for key == NULL in json_object_get and json_object_del 2013-12-28 06:11:49 +01:00
Chip Salzenberg a76dc45512 paper bag bug: json_string_set* functions should set the length too 2013-10-03 19:07:20 -07:00
Chip Salzenberg 9c259c07aa Support \u0000 - add size_t string lengths to API, load and dump \u000, etc.
Also:
  Steal strings during parsing for half the mallocs!
  Change all input-caused assertions to errors.  No crashes please, we're programmers.
2013-09-27 17:32:06 -07:00
Petri Lehtinen 2489ea90b1 Update copyrights for 2013 2013-07-23 13:20:06 +03:00
Petri Lehtinen 8490e377c0 Make the argument of json_deep_copy() const
Fixes #126.
2013-07-08 12:36:56 +03:00
Petri Lehtinen 6281d1c549 Merge pull request #108 from Zillode/1edff47af38a2335f88300ee6dc437118f5a20ff
Fixes redefined warnings ("_GNU_SOURCE")
2013-04-02 05:40:49 -07:00
Lode Hoste 1edff47af3 Do not define _GNU_SOURCE is already defined 2013-03-14 21:34:11 +01:00
Petri Lehtinen e0a7f81b39 Really fix the off-by-one error in json_array_remove()
It didn't affect only the last element but all of them. One item too
much was always moved.
2012-12-04 21:20:59 +02:00
Petri Lehtinen 54d59c743c Fix an off-by-one error in json_array_remove()
Uninitialized memory was read when the last item of a "full" array was
removed.
2012-12-04 09:32:45 +02:00
Petri Lehtinen 4118315afa Disallow NaN or Inf real values 2012-09-13 21:30:19 +03:00
Petri Lehtinen ee13c667f1 Fix json_real_set() to return -1 on error 2012-09-13 08:46:56 +03:00
Petri Lehtinen ff0c05b8f1 Support building on Windows
Jansson now builds correctly with Visual C++ Express 2010.
2012-04-29 22:09:29 +03:00
Petri Lehtinen 3c6e36ba2d Update copyright notices for 2012 2012-03-20 20:55:55 +02:00
Petri Lehtinen fa268b5017 Add json_object_update_{existing,missing}
Closes #37.
2012-01-24 21:03:36 +02:00
Petri Lehtinen a307974731 Implement json_object_foreach()
Also change many places to use it internally to replace hand-crafted
iteration.

Closes #45, #46.
2012-01-24 21:01:24 +02:00
Petri Lehtinen a2381948bb Make hashtable less generic
This will make it possible to implement json_object_foreach(). It
should also have some (positive) effect on speed.
2012-01-24 21:01:23 +02:00
Petri Lehtinen 5eb2c442a9 Fix a potential memory leak 2012-01-24 20:35:59 +02:00
Petri Lehtinen 0f2cdd70ff Avoid problems with object's serial number growing too big
Transform serial key comparison from substraction to real comparison.
Reset serial to zero in json_object_clear() to avoid it growing out of
bounds when reusing objects.

Closes GH-40.
Closes GH-41.
2011-11-14 21:01:13 +02:00
Petri Lehtinen c0193bfb7f Check that target is string and value is not NULL in json_string_set() 2011-06-17 21:42:19 +03:00
Petri Lehtinen e20619e071 Fix a leak when memory allocation fails in json_object_set() & friends 2011-04-21 13:15:22 +03:00
Petri Lehtinen 0944ac8d91 Fix invalid object key hashing in json_unpack() strict checking mode
The keys which are stored temporarily to a hashtable to make sure that
all object keys are unpacked, were hashed with the object key hashing
function. It is meant to compute hashes for object_key_t values, and
it works incorrectly for plain strings.

Fixed by introducing suitable functions for hashing and comparing
strings for string-keyed hashtables.
2011-03-30 12:57:48 +03:00
Petri Lehtinen 6ecba84817 Fix json_object_size() return value
Return 0 as documented if the argument is not a JSON object.

Closes GH-18.
2011-03-21 08:22:34 +02:00
Petri Lehtinen 4be9e9e7fe Add custom memory allocation
Thanks to Basile Starynkevitch for the suggestion and initial patch.
Thanks to Jonathan Landis and Deron Meranda for showing how this can
be utilized for implementing secure memory operations.
2011-02-17 10:10:53 +02:00
Petri Lehtinen 2770dca2c0 Add validation features to json_unpack()
* By default, json_unpack() now checks that all items of arrays and
  objects are unpacked. This is useful for validation.

* Add format specifier '*' to suppress this check for individual
  arrays and objects. '*' must appear as the last format specifier
  before the closing ']' or '}'.
2011-01-25 08:53:55 +02:00
Petri Lehtinen fa7c2ea070 Update copyright notices for 2011 2011-01-22 13:43:14 +02:00
Petri Lehtinen 06eb436008 Move max() to jansson_private.h, define only if not already defined
On some platforms (Visual C++ for one) the standard library already
defines max() as a macro.
2010-09-05 21:18:46 +03:00
Petri Lehtinen e3654c2245 Don't use designated struct initializers
It's a C99 feature and not available on all compilers (Visual C++, for
example).
2010-09-05 21:18:46 +03:00
Petri Lehtinen 976fc2279f Replace all occurences of inline with JSON_INLINE
This makes it easier to compile without the configure script (e.g. on
Windows).
2010-09-05 21:18:46 +03:00
Petri Lehtinen 56643d4311 Merge branch '1.3'
Conflicts:
	doc/apiref.rst
	src/jansson_private.h
2010-08-14 21:02:08 +03:00
Petri Lehtinen ffbab6fedd Change the underlying type of JSON integer from long to json_int_t
json_int_t is typedef'd to long long if it's supported, or long
otherwise. There's also some supporting things, like the
JSON_INTEGER_FORMAT macro that expands to the printf() conversion
specifier that corresponds to json_int_t's actual type.

This is a backwards incompatible change.
2010-08-13 22:07:20 +03:00
Petri Lehtinen 145032a57f Make object_key_t portable
A flexible array member is unportable. Use a table of length 1
instead. This needs some adjustment to the memory allocatio, too.
2010-08-12 21:35:23 +03:00
Petri Lehtinen 014c49c285 Change JSON integer's underlying type from int to long
This is a backwards incompatible change.
2010-08-10 21:45:18 +03:00
Petri Lehtinen 68f2861e92 Unify unsigned integer usage in the API
Replace all occurences of unsigned int and unsigned long with size_t.

This is a backwards incompatible change, as the signature of many API
functions changes.
2010-06-15 15:38:59 +03:00
Petri Lehtinen 4e63fcd55d Merge branch '1.2'
Conflicts:
	configure.ac
2010-03-28 21:44:41 +03:00
Petri Lehtinen 29ee3832cf Support compilers that don't have the "inline" keyword
Use AC_C_INLINE autoconf macro, include config.h where needed, and add
a define of JSON_INLINE to jansson.h that has the correct "inline"
keyword.
2010-03-28 21:14:08 +03:00
Petri Lehtinen 49880cbabe Merge branch '1.2' 2010-03-23 08:15:19 +02:00
Petri Lehtinen f284e3c069 Fix reference counting on true, false and null
Initialize their reference counts to (unsigned int)-1 to disable
reference counting on them. It already was meant to work like this,
but the reference counts were just initialized to 1 instead of -1.

Thanks to Andrew Thompson for reporting this issue.
2010-03-23 08:12:32 +02:00
Petri Lehtinen f18ef5144a Implement JSON_PRESERVE_ORDER encoding flag
With this encoding flag, the object key-value pairs in output are in
the same order in which they were first inserted into the object.

To make this possible, a key of an object is now a serial number plus
a string. An object keeps an increasing counter which is used to
assign serial number to the keys. Hashing, comparison and public API
functions were changed to act only on the string part, i.e. the serial
number is ignored everywhere else but in the encoder, where it's used
to order object keys if JSON_PRESERVE_ORDER flag is used.
2010-02-11 20:48:56 +02:00
Petri Lehtinen 8d75235ff2 Merge branch '1.2'
Conflicts:
	LICENSE
2010-02-04 21:13:57 +02:00
Petri Lehtinen 08dc8d9baf Add year 2010 to copyright notices 2010-02-02 21:26:11 +02:00
Petri Lehtinen b495b96547 Add functions json_object_iter_{at,set,set_new} 2010-02-01 21:07:19 +02:00
Petri Lehtinen 93ac06c902 Fix memory leaks in json_*_deep_copy() 2010-01-10 21:01:07 +02:00
Petri Lehtinen 508873de9b Use _nocheck functions internally for speed
There are some places where we copy a string from an existing JSON
value. In these cases the string has already been checked for valid
UTF-8.
2010-01-10 14:39:11 +02:00
Petri Lehtinen 9db34dc31a Add functions for shallow and deep copying JSON values 2009-12-31 18:50:39 +02:00