Simon Resch
0c3588330a
Set error codes for truncating int conversions
...
json_object_get_int/int64/uint64() now sets errno to ERANGE when the source value
can't be represented in the target type.
2024-11-27 07:17:20 +01:00
Simon Resch
8c13801f2c
Explicitly handle NaN values when converting to int
...
Json objects of type double with the value NaN could cause undefined
behavior when casting double to int in `json_object_get_int`.
2024-11-27 07:17:20 +01:00
Eric Hawicz
61016412fb
Issue #850 : fill in & adjust the "@returns" docs for several functions.
2024-03-29 18:46:05 -04:00
Federico Francescon
9c44c7ed52
docs: micro typo in json_object_get doc
2024-03-02 22:41:10 +01:00
Alexandru Ardelean
a86d7a8f5a
json_object: introduce json_object_array_insert_idx() API function
...
The behavior of the json_object_array_put_idx() is that, if a user wants to
insert an element inside a JSON array, the element will be replaced.
For some cases, a user would want to insert an element into the JSON array
and shift the elements to the right.
For indexes that are outside the length of the current array this behaves
like json_object_array_put_idx().
If a user wants to enforce that the JSON array is not expanded, then the
json_object_array_length() function can be used to guard against that.
The main driver for this change is JSON patch, where the 'add' operation in
an array means inserting a value at a certain index and shifting everything
by one.
Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com >
2023-07-31 22:17:30 -04:00
Matthias Gatto
9803032b9d
add JSON_C_TO_STRING_COLOR option
...
This option enable color in json_object_to_json_string_ext.
I've try to made something similar to jq output,
but I've color true/false and null in purple,
as it's what is common color scheme used in programing language in emacs.
also add a '-c' option into json_parser to test it.
note: that I could have done a color() function similar to
what is done with indent(), but as the code is pretty small
I've keep it as it. so if you want me to use a subfunction
tell me and I'll do it.
Signed-off-by: Matthias Gatto <matthias.gatto@protonmail.com >
2023-07-10 20:45:20 +02:00
Tobias Stoeckmann
cbc603b587
Adjusted URLs
...
Most of these sites support HTTPS (some forward to HTTPS when accessing
the HTTP versions). Use HTTPS directly if supported.
Some URLs led to 404 error pages. Adjusted the links to point to
new locations.
I did not adjust the Microsoft HTML Help Workshop link because it seems
that this software is not available anymore. Instead of removing the
link entirely I kept it there in case it helps someone to find the
software on archived websites.
2022-03-19 10:34:55 +01:00
Even Rouault
3bb54f97e7
Fix typos in code comments and ChangeLog
2022-02-25 00:14:47 +01:00
Eric Haszlakiewicz
2d2382d709
Add linkhash accessor functions (lh_table_head(), lh_entry_next(), etc...) to pave the way for making the lh_table and lh_entry structure opaque in the future.
...
Update the docs to mark all members of those structures deprecated, and
suggest what to use instead.
2021-11-30 03:27:55 +00:00
José Bollo
8bf3b45a29
Really use prefix JSON_C_OBJECT_ADD_*
...
This change introduces JSON_C_OBJECT_ADD_CONSTANT_KEY
as a replacement of JSON_C_OBJECT_KEY_IS_CONSTANT.
The description of json_object_object_add_ex tells to
look at the flags JSON_C_OBJECT_ADD_* but it is not
for JSON_C_OBJECT_KEY_IS_CONSTANT.
From the point of vue of a developper using json-c,
the function json_object_object_add_ex is mainly used,
not the hash facility, it seems more natural to provide
a regular naming of prefix JSON_C_OBJECT_ADD_CONSTANT_KEY.
2021-10-19 11:18:17 +02:00
David McCann
00098efc96
Merge branch 'json-c:master' into master
2021-05-13 06:34:10 +01:00
David McCann
9b53c92ea3
Check __STDC_VERSION__ is defined before checking its value
...
Prevent an undef warning regarding __STDC_VERSION__ by checking whether it is defined before checking its value.
2021-05-13 06:31:18 +01:00
Eric Haszlakiewicz
2b439ea598
Fix json_object_get_boolean() doc for the object and array cases (always returns 0), and add those cases to the test_cast test.
...
See also issue #658 .
2020-08-17 14:57:21 +00:00
Eric Haszlakiewicz
cb10a13e94
Remove the THIS_FUNCTION_IS_DEPRECATED define, we stopped using it long ago.
2020-07-17 03:20:29 +00:00
Eric Haszlakiewicz
4d9f6dd22e
Issue #642 : improve the docs for json_object_put() and json_object_get().
2020-07-12 18:43:27 +00:00
Eric Haszlakiewicz
2330c6f0de
Expand the doc for json_object_array_get_idx() to explain that it does not adjust refcounts.
2020-07-12 17:55:46 +00:00
Eric Haszlakiewicz
10a9ac245e
Issue #642 : improve docs for json_tokener.h and json_object_object_add().
2020-07-11 04:04:58 +00:00
Eric Haszlakiewicz
0b67caec1a
Add doc comment for json_object_new_array_ext().
2020-06-29 02:31:32 +00:00
Eric Haszlakiewicz
e26a1195f4
Add json_object_array_shrink() (and array_list_shrink()) and use it in json_tokener to minimize the amount of memory used. This results in a 39%-50% reduction in memory use (peak RSS, peak heap usage) on the jc-bench benchmark and 9% shorter runtime.
...
Also add the json_object_new_array_ext, array_list_new2, and array_list_shrink functions.
2020-06-20 18:03:04 +00:00
Björn Esser
d0dc3489dc
Enforce strict prototypes.
2020-04-13 11:29:52 +02:00
Björn Esser
78cd37fb18
Clean trailing white-space.
2020-04-11 09:41:04 +02: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
6359b79847
update json_object.c and testcase, delete json_object_uint_inc()
2020-02-28 17:51:56 +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
Eric Haszlakiewicz
518f337ce8
Issue #539 : use a internal-only serializer function in json_object_new_double_s() to avoid potential conflicts with user code that uses the json_object_userdata_to_json_string serializer. Also, document the serializer-resetting behavior of json_object_set_double().
2020-02-14 03:48:02 +00:00
dota17
7ad72b81c5
update comment
2020-01-22 09:56:52 +08:00
dota17
010f33d460
add json_object_new_null
2020-01-20 16:46:46 +08:00
Eric Haszlakiewicz
7f30afc6e5
Fix some Windows compile issues, add JSON_EXPORT's, fix bogus character escapes, define __func__ and omit unistd.h if needed.
2019-11-23 20:31:14 -05:00
Eric Haszlakiewicz
eae040a84a
Issue #488 : use JSON_EXPORT on functions so they are properly exported on Windows.
2019-09-08 22:42:36 -04:00
andy5995
2942870325
remove [in] from params description
...
Keeping this would be inconsistent with the other documentation
2018-11-28 16:55:19 -06:00
andy5995
3b108935d0
json_object.h:document json_object_new_string_len()
...
I also added a couple trivial, but related, suggestions.
closes #460
2018-11-27 11:35:45 -06:00
Eric Haszlakiewicz
c1c71097a1
Issue #419 : document that NULL may be passed to json_object_put().
2018-06-12 23:16:31 -04:00
janczer
8bd62177e7
Fixed typos
2018-04-24 16:00:38 +02:00
Jonathan Wiens
cdc4e9f64b
Avoid uninitialized variable warnings
...
Fix json_object_object_foreach to avoid uninitialized variable warnings
using ANSI C or MSC.
2018-01-17 15:57:52 +01:00
Eric Haszlakiewicz
0992aac61f
Remove the TRUE and FALSE defines.
2017-12-23 09:42:17 -05:00
Rikard Falkeborn
84dcc01da1
Fix non-GNUC define for JSON_C_CONST_FUNCTION
2017-12-13 22:29:16 +01:00
Eric Haszlakiewicz
5b6d62259a
Apply gcc's "const" attribute to the json_c_object_sizeof() function as an optimizer hint. Also, rename that function from json_object_sizeof().
2017-12-12 18:26:51 -05:00
Björn Esser
c123a1c21b
json_object: Add size_t json_object_sizeof()
2017-12-11 16:16:15 +01:00
Eric Haszlakiewicz
d582d3ae5a
Undeprecate the array_list, lh_table and printbuf typedefs, but move each to the corresponding header files.
2017-12-06 23:58:33 -05:00
Eric Haszlakiewicz
8c82f0e5c3
Squash doxygen warnings, and make a few slight improvements to the docs.
2017-12-06 23:53:12 -05: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
aedd36ac8b
Make sure to include the "*" on function pointer arguments to avoid a warnings from VS2015. See also PR#384.
2017-12-04 18:17:52 -05:00
ssrlive
7709cb1355
Fix a VS 2015 compiler warning.
...
In VS 2015, the warning text is "warning C4550: expression evaluates to a function which is missing an argument list".
2017-12-04 14:43:25 +08:00
Eric Haszlakiewicz
5dae561d33
In json_object_deep_copy(), copy over _userdata, at least for json_type_string's with the default serializer set, and provide a way for people using custom serializers to provide a custom shallow_copy method.
2017-11-29 23:35:38 -05:00
Eric Haszlakiewicz
4dd92180c6
Merge branch 'json_deep_copy' of https://github.com/commodo/json-c into commodo-json_deep_copy
2017-11-29 09:12:59 -05:00
Eric Haszlakiewicz
3628f16dd6
Rename json_object_add_int() to json_object_int_inc() and eliminate the "int64" variant since we store 64-bit values internally anyway.
2017-11-27 17:57:36 -05:00