summaryrefslogtreecommitdiff
path: root/json_object.c
AgeCommit message (Collapse)AuthorFilesLines
2015-03-04Slight style tweaks to the bsearch changest.Eric Haszlakiewicz1-7/+5
2014-08-21add bsearch for arraysAlexander Dahl1-0/+17
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-04-19Check for failures when allocating memory; return NULL and set errno=ENOMEM ↵Eric Haszlakiewicz1-1/+26
in a few of those cases. Thanks to Susant Sahani for pointing out some of these.
2014-04-19Reformat some code in json_object.cEric Haszlakiewicz1-198/+231
2014-03-02Issue#114: check for the presence of isnan and isinf, and provide compat ↵Eric Haszlakiewicz1-0/+1
macros on MSCV where _isnan and _finite exist instead.
2013-10-01Avoid potential overflow in json_object_get_doubleKeith Derrick1-1/+32
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.
2013-09-11Issue #59: change the floating point output format to %.17g so values with ↵Eric Haszlakiewicz1-1/+1
more than 6 digits show up in the output.
2013-09-11Use sizeof instead of hard coded values when calling snprintf.Eric Haszlakiewicz1-4/+4
2013-09-11Added a json_object_new_double_s() convenience function to allow an exact ↵Eric Haszlakiewicz1-5/+30
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.
2013-09-08Merge pull request #96 from rouault/remove_strdnupEric Haszlakiewicz1-4/+0
Remove redefinition of strndup() which is no longer used in the codebase
2013-08-12Remove redefinition of strndup() which is no longer used in the codebaseEven Rouault1-4/+0
2013-08-04fixing problem that isinf(-Inf) can be 1 or -1Taneli Mielikainen1-4/+5
2013-06-18Merge pull request #89 from ayanes/masterEric Haszlakiewicz1-1/+13
Support NaN and Infinity
2013-06-12Fixes for Infinity and NaNAdrian Yanes1-1/+13
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
2013-06-04snprintf definition is needed here, tooAnatol Belski1-0/+7
2013-02-26Merge branch 'remicollet-issue-float'Eric Haszlakiewicz1-1/+22
Conflicts: json_util.c
2013-01-11add json_object_object_lengthGreg Hazel1-0/+5
2012-12-24escape '\f' in json_escape_strAbioy1-0/+2
'\f' is a llegal char and should be escape in printbuf
2012-12-13probably worth an option for thisRemi Collet1-1/+1
2012-12-13Save space, drop unuseful trailing zeroesRemi Collet1-1/+13
2012-12-13Simple fix to double encodeRemi Collet1-1/+10
2012-12-09Fix issue #53 - ensure explicit length string are still NUL terminated, and ↵Eric Haszlakiewicz1-1/+2
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
2012-10-18Reformat json_object_object_get() and json_object_object_get_ex().Eric Haszlakiewicz1-13/+14
2012-10-18Fix json_object_object_get() so it returns NULL if the incoming json_object ↵Eric Haszlakiewicz1-1/+4
is NULL.
2012-10-18Change json_object_put to return 1 if the object passed was actually freed. ↵Eric Haszlakiewicz1-2/+4
(or 0 if only the reference count was decremented)
2012-09-02Add a json_set_serializer() function to allow the string output of a ↵Eric Haszlakiewicz1-4/+68
json_object to be customized.
2012-07-24Rewrite json_object_object_add to replace just the value if the key already ↵Eric Haszlakiewicz1-2/+14
exists so keys remain valid. This is particularly useful when replacing values in a loop, since it allows the key used by json_object_object_foreach to continue to be used.
2012-05-22Missing explicit casts from void* to specific pointers required. Added ↵Mateusz Loskot1-1/+1
#define strcasecmp for Visual C++.
2012-05-21Replaced #if HAVE_X with #ifdef HAVE_X as the former test is troublemaker ↵Mateusz Loskot1-1/+8
with #define HAVE_X where #define HAVE_X 1|0 is meant.
2012-04-29Change the format used for sprintbuf (but not scanf) to use %f instead of ↵Eric Haszlakiewicz1-1/+1
%lf because the "l" is unnecessary and some compilers behave differently with it present (e.g. MinGW). Thanks for Mateusz Loskot for the fix.
2012-04-28Add a json_object_to_json_string_ext() function to allow the formatting of ↵Eric Haszlakiewicz1-44/+120
output to be selected. There are now three options: JSON_C_TO_STRING_SPACED, JSON_C_TO_STRING_PLAIN and JSON_C_TO_STRING_PRETTY. This also add a json_object_to_file_ext() that takes the same flags. Existing output of json_object_to_json_string() is unchanged, and uses JSON_C_TO_STRING_SPACED. Thanks fo Grant Edwards for the initial patches.
2012-04-24Since we already use a local json_bool type, replace any stdbool.h usage withEric Haszlakiewicz1-1/+0
that, since not all environments actually have a stdbool.h to use.
2012-04-12Add NULL-safe get object methodKeith Derrick1-2/+21
New json_object_object_get_ex() method protects itself against null pointers and invalid objects being passed in.
2012-03-31Adjust json_object_is_type and json_object_get_type so they return ↵Eric Haszlakiewicz1-0/+4
json_type_null for NULL objects.
2012-03-26Rename boolean type to json_boolKeith Derrick1-2/+2
In building large systems, there are often clashes over the preferred base type to use for bool/boolean. At least one experience has been with a 3rd party proprietary library which can not be changed. In that case, boolean was a synonym for unsigned char and used widely in packed structures.
2012-02-01Some updates to make the code compatible with VC 9 (2008)John Arbash Meinel1-2/+5
VC 9 doesn't support late variable declarations, and doesn't have inttypes so we need some direct definitions of a couple of more types.
2011-10-30Added capitalized charaters to json_hex_charsFederico Culloca1-1/+1
2011-10-07Add new json_object_array_sort functionFrederik Deweerdt1-0/+5
- uses libc's qsort to sort the arraylist - add test in test1.c
2011-05-26handle NULL passed to json_objct_object_getJehiah Czebotar1-0/+1
Patch via Nikola Pajkovsky git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@75 327403b1-1117-474d-bef2-5cb71233fd97
2011-05-03Add a json_type_to_name() function which returns a string that describes the ↵Eric Haszlakiewicz1-16/+3
type. Useful for logging. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@67 327403b1-1117-474d-bef2-5cb71233fd97
2011-05-03Fix a bug in json_object_get_int() where calling it on a string type object ↵Eric Haszlakiewicz1-1/+1
would always return 0, instead of the actual numerical value of the string. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@66 327403b1-1117-474d-bef2-5cb71233fd97
2011-01-14update json_object_new_string_len, json_escape_str (internal). Writer ↵Jehiah Czebotar1-15/+26
handles \x00 correctly Added parse_null test. This does not change anything with how the parser handles \u0000 or null characters This commit is addapted from one by Adomas Paltanavičius <adomas@leanholding.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@63 327403b1-1117-474d-bef2-5cb71233fd97
2010-12-07Simplify things by storing integer values only as int64_t's internally, andehaszla1-17/+4
omit the range check during parsing since we already have the checks when accessing the value. There is no longer a json_type_int64, only json_type_int. Fix some problems with parsing 0 and -0 values, and add a couple of tests. Fix some minor compile issues on HPUX environments. git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@60 327403b1-1117-474d-bef2-5cb71233fd97
2010-10-06 * Add int64 support. Two new functions json_object_net_int64 andMichael Clark1-6/+66
json_object_get_int64. Binary compatibility preserved. Eric Haszlakiewicz, EHASZLA at transunion com Rui Miguel Silva Seabra, rms at 1407 dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@56 327403b1-1117-474d-bef2-5cb71233fd97
2009-06-30Disable REFCOUNT_DEBUG by default in json_object.cChristopher Watford1-1/+1
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@40 327403b1-1117-474d-bef2-5cb71233fd97
2009-04-27Fix json_object_get_boolean to return false for empty stringMichael Clark1-1/+1
Spotted by Vitaly Kruglikov, Vitaly dot Kruglikov at palm dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@35 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 * Don't use this as a variable, so we can compile with a C++ compilerMichael Clark1-1/+3
* Add casts from void* to type of assignment when using malloc * Add #ifdef __cplusplus guards to all of the headers * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table Michael Clark, <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@33 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 * Don't use this as a variable, so we can compile with a C++ compilerMichael Clark1-143/+143
Michael Clark, <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@32 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 * Null pointer dereference fix. Fix json_object_get_boolean strlen testMichael Clark1-2/+1
to not return TRUE for zero length string. Remove redundant includes. Erik Hovland, erik at hovland dot org git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@31 327403b1-1117-474d-bef2-5cb71233fd97
2009-02-25 * Fixed warning reported by adding -Wstrict-prototypesMichael Clark1-2/+2
-Wold-style-definition to the compilatin flags. Dotan Barak, dotanba at gmail dot com git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@30 327403b1-1117-474d-bef2-5cb71233fd97