Commit Graph

30 Commits

Author SHA1 Message Date
Eric Haszlakiewicz
66d91fdf86 The split of json_object into type-specific sub-structures is now functionally complete.
Remove all of the temporary defines, structures, old compat fuctions, extra fields, etc... that were needed during the conversion to a split set of json_object_* structures.
2020-06-07 17:23:56 +00:00
Eric Haszlakiewicz
0fc9d91277 Kick json_type_string out of struct json_object.
The default is now that string data is stored inline at the end of json_object, though to allow for json_object_set_string() to set a _longer_ string, we still need to allow for the possibility of a separate char * pointer.
All json types have been split out now, next step it cleanup.
2020-06-07 02:56:59 +00:00
Eric Haszlakiewicz
9ecb1222bd Kick json_type_int and json_type_double out of struct json_object.
Clean up the code in json_object_new_* a bit by dropping unnecesary json_object_base variables.
2020-05-26 02:31:35 +00:00
Eric Haszlakiewicz
d1f83bf5ea Kick json_type_boolean out of struct json_object. 2020-05-25 04:05:32 +00:00
Eric Haszlakiewicz
02b687b9a6 Kick json_type_array out of struct json_object; re-enable the test_deep_copy test. 2020-05-25 03:44:56 +00:00
Eric Haszlakiewicz
853b4b5dee Start splitting struct json_object into multiple sub-types, as descibed at https://github.com/json-c/json-c/wiki/Proposal:-struct-json_object-split
The current changes split out _only_ json_type_object, and thus have a number of hacks
 to allow the code to continue to build and work.

Originally  mentioned in issue #535.
When complete, this will probably invalidate #552.
This is likely to cause notable conflicts in any other significant un-merged
changes, such as PR#620.
2020-05-25 03:18:36 +00:00
Eric Haszlakiewicz
19bbf2c069 Add includes and split off json_types.h to help ensure that headers can be included in any order. 2020-04-06 13:55:27 +00:00
dota17
8b162c4b89 clang-format the files 2020-04-03 11:39:30 +08:00
dota17
c117d8a8a8 add the disabling formatting coments and adjust the partial code manuly 2020-04-03 11:28:04 +08:00
dota17
9532f94fa4 modify partial functions and testcase, in order to support automatic conversion for int64/uint64 2020-02-28 09:25:02 +08:00
dota17
c816de212b modify the json_object, replace c_int64/c_uint64 with struct{union{int64, uint64},...} 2020-02-27 10:26:27 +08:00
dota17
3c3b5920f7 add uint64 data to json-c 2020-02-25 14:51:35 +08:00
Ramiro Polla
5bb5e2e8fc json_object_private: save 8 bytes in struct json_object in 64-bit architectures
- there is no need for _ref_count to be uint_fast32_t (the compiler
  might decide to use a 64-bit int). make it uint32_t instead.
- reorder the 32-bit integer fields (o_type and _ref_count) so that
  there is no wasted 4-byte gap after each of them.
2018-11-24 04:16:36 +01:00
Björn Esser
c233f5c05e json_object_private: Use unsigned 32-bit integer type for refcount 2017-12-17 12:51:17 +01:00
Eric Haszlakiewicz
f2f103b986 Add a brief overview of each file to the docs. 2017-12-06 00:20:59 -05:00
Eric Haszlakiewicz
11ab365324 Deprecated a few typedefs, add docs on json_object_iter, move json_number_chars and json_hex-chars to json_object_private.h. 2017-12-05 09:20:59 -05:00
Eric Haszlakiewicz
437716c5b4 Rename _set_last_err() to _json_c_set_last_err(). 2017-11-29 09:36:53 -05:00
Eric Haszlakiewicz
8581806558 Make _set_last_err() non-static so it can be used outside of json_util.c 2017-06-18 18:11:17 +00: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
Eric Haszlakiewicz
38f421a2e7 Add a json_set_serializer() function to allow the string output of a json_object to be customized. 2012-09-02 15:21:56 -05:00
Eric Haszlakiewicz
3fcffe1bb0 Add a json_object_to_json_string_ext() function to allow the formatting of 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-28 13:26:09 -05:00
Keith Derrick
37e7467476 Rename boolean type to json_bool
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-03-26 14:29:31 -07:00
Jehiah Czebotar
43d2f417c7 move definition of json_object_iter to public header to enable external use of json_object_object_foreachC
Patch from Rick Moran <https://github.com/DrHayt>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@74 327403b1-1117-474d-bef2-5cb71233fd97
2011-05-25 04:49:20 +00:00
Jehiah Czebotar
ac601b5b5f update json_object_new_string_len, json_escape_str (internal). Writer 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
2011-01-14 17:23:06 +00:00
ehaszla
252669cee6 Simplify things by storing integer values only as int64_t's internally, and
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-12-07 18:15:35 +00:00
Michael Clark
c4dceae1c5 * Add int64 support. Two new functions json_object_net_int64 and
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
2010-10-06 16:39:20 +00:00
Michael Clark
aaec1ef3c5 * Don't use this as a variable, so we can compile with a C++ compiler
* 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 02:31:32 +00:00
Michael Clark
f6a6e486ff * Make headers C++ compatible by change *this to *obj
* Add ifdef C++ extern "C" to headers
  * Use simpler definition of min and max in bits.h
    Larry Lansing, llansing at fuzzynerd dot com

  * Remove automake 1.6 requirement
  * Move autogen commands into autogen.sh. Update README
  * Remove error pointer special case for Windows
  * Change license from LGPL to MIT
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@10 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:23 +00:00
Michael Clark
4504df7117 * printbuf.c - C. Watford (christopher dot watford at gmail dot com)
Added a Win32/Win64 compliant implementation of vasprintf
  * debug.c - C. Watford (christopher dot watford at gmail dot com)
    Removed usage of vsyslog on Win32/Win64 systems, needs to be handled
    by a configure script
  * json_object.c - C. Watford (christopher dot watford at gmail dot com)
    Added scope operator to wrap usage of json_object_object_foreach, this
    needs to be rethought to be more ANSI C friendly
  * json_object.h - C. Watford (christopher dot watford at gmail dot com)
    Added Microsoft C friendly version of json_object_object_foreach
  * json_tokener.c - C. Watford (christopher dot watford at gmail dot com)
    Added a Win32/Win64 compliant implementation of strndup
  * json_util.c - C. Watford (christopher dot watford at gmail dot com)
    Added cast and mask to suffice size_t v. unsigned int conversion
    correctness
  * json_tokener.c - sign reversal issue on error info for nested object parse
    spotted by Johan Bj�rklund (johbjo09 at kth.se)
  * json_object.c - escape " in json_escape_str
  * Change to automake and libtool to build shared and static library
    Michael Clark <michael@metaparadigm.com>


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@4 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:20 +00:00
Michael Clark
f0d08887b8 import of version 0.1
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@2 327403b1-1117-474d-bef2-5cb71233fd97
2007-03-13 08:26:18 +00:00