]> git.ipfire.org Git - thirdparty/json-c.git/log
thirdparty/json-c.git
3 months agoIssue #867 - also disallow control characters in keys master
Eric Hawicz [Fri, 4 Apr 2025 01:09:05 +0000 (21:09 -0400)] 
Issue #867 - also disallow control characters in keys

5 months agoMerge pull request #884 from careles/mingw_win64-WIN32_LEAN_AND_MEAN-redefined
Eric Hawicz [Thu, 9 Jan 2025 05:12:09 +0000 (00:12 -0500)] 
Merge pull request #884 from careles/mingw_win64-WIN32_LEAN_AND_MEAN-redefined

fix macro WIN32_LEAN_AND_MEAN redefined

6 months agofix macro WIN32_LEAN_AND_MEAN redefined 884/head
Careles [Mon, 6 Jan 2025 02:56:53 +0000 (10:56 +0800)] 
fix macro WIN32_LEAN_AND_MEAN redefined

json-c as add_subdirectory and project cmakelists.txt has add_definitions(-DWIN32_LEAN_AND_MEAN)

6 months agoMerge pull request #872 from GitMensch/patch-2
Eric Hawicz [Sun, 29 Dec 2024 18:34:38 +0000 (13:34 -0500)] 
Merge pull request #872 from GitMensch/patch-2

fix linkhash breaking -std=c89

6 months agoMerge pull request #847 from sacredbanana/amiga
Eric Hawicz [Sun, 29 Dec 2024 18:26:11 +0000 (13:26 -0500)] 
Merge pull request #847 from sacredbanana/amiga

Add support for Commodore Amiga

6 months agoMerge pull request #882 from simonresch/handle-nan-to-int-conversion
Eric Hawicz [Fri, 27 Dec 2024 00:07:07 +0000 (19:07 -0500)] 
Merge pull request #882 from simonresch/handle-nan-to-int-conversion

Explicitly handle NaN values when converting to integer

6 months agoAdd support for MorphOS 847/head
Cameron Armstrong (Nightfox) [Fri, 30 Aug 2024 19:57:46 +0000 (03:57 +0800)] 
Add support for MorphOS

6 months agoRemove linking to libamiga and libc
Cameron Armstrong (Nightfox) [Mon, 5 Aug 2024 04:50:47 +0000 (12:50 +0800)] 
Remove linking to libamiga and libc

6 months agoDo not use duplocale if building for libnix because it isnt supported yet
Cameron Armstrong (Nightfox) [Mon, 15 Jul 2024 03:30:44 +0000 (11:30 +0800)] 
Do not use duplocale if building for libnix because it isnt supported yet

6 months agoClean up CMakeLists.txt and remove Amiga specific locale.h guard
Cameron Armstrong (Nightfox) [Sat, 22 Jun 2024 10:49:50 +0000 (18:49 +0800)] 
Clean up CMakeLists.txt and remove Amiga specific locale.h guard

6 months agoFix Readme
Cameron Armstrong (Nightfox) [Sat, 22 Jun 2024 05:45:15 +0000 (13:45 +0800)] 
Fix Readme

6 months agoGet working ror libnix and clib2
Cameron Armstrong [Wed, 27 Dec 2023 23:53:32 +0000 (07:53 +0800)] 
Get working ror libnix and clib2

6 months agoAdd support for Commodore Amiga
Cameron Armstrong [Sat, 23 Dec 2023 11:47:38 +0000 (19:47 +0800)] 
Add support for Commodore Amiga

6 months agoMerge pull request #879 from janotomko/null
Eric Hawicz [Sat, 7 Dec 2024 18:33:05 +0000 (13:33 -0500)] 
Merge pull request #879 from janotomko/null

Handle NULL gracefully in json_tokener_free

7 months agoSet error codes for truncating int conversions 882/head
Simon Resch [Tue, 26 Nov 2024 19:42:29 +0000 (20:42 +0100)] 
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.

7 months agoExplicitly handle NaN values when converting to int
Simon Resch [Thu, 14 Nov 2024 12:47:18 +0000 (13:47 +0100)] 
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`.

7 months agoMerge pull request #878 from 0xfadead/readme-fix-underline
Eric Hawicz [Sun, 24 Nov 2024 00:39:50 +0000 (19:39 -0500)] 
Merge pull request #878 from 0xfadead/readme-fix-underline

Fix underline bug in README

7 months agoMerge pull request #883 from simonresch/add-oss-fuzz-tests
Eric Hawicz [Sun, 24 Nov 2024 00:39:13 +0000 (19:39 -0500)] 
Merge pull request #883 from simonresch/add-oss-fuzz-tests

Add fuzz tests for json_object/point/array apis

7 months agoAdd fuzz tests for json_object/point/array apis 883/head
Simon Resch [Sat, 9 Nov 2024 03:20:40 +0000 (22:20 -0500)] 
Add fuzz tests for json_object/point/array apis

Extends the coverage of fuzz tests executed in OSS-Fuzz.

7 months agoIssue #881: don't allow json_tokener_new_ex() with a depth < 1
Eric Hawicz [Mon, 18 Nov 2024 03:11:24 +0000 (22:11 -0500)] 
Issue #881: don't allow json_tokener_new_ex() with a depth < 1

7 months agoFix issue #875: cast to unsigned char so bytes above 0x7f aren't interpreted as negat...
Eric Hawicz [Sat, 9 Nov 2024 03:20:40 +0000 (22:20 -0500)] 
Fix issue #875: cast to unsigned char so bytes above 0x7f aren't interpreted as negative, which was causing the strict-mode control characters check to incorrectly trigger.

7 months agoHandle NULL gracefully in json_tokener_free 879/head
Ján Tomko [Wed, 6 Nov 2024 14:19:04 +0000 (15:19 +0100)] 
Handle NULL gracefully in json_tokener_free

Similarly to glibc's free, make json_tokener_free(NULL)
a no-op, to simplify cleanup paths.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
8 months agoFix the apps/json_parse "-s" (strict) option so it actually does something, and defau...
Eric Hawicz [Mon, 4 Nov 2024 00:44:21 +0000 (19:44 -0500)] 
Fix the apps/json_parse "-s" (strict) option so it actually does something, and default to non-strict.

8 months agoFix underline bug in README 878/head
Awildidiot [Sun, 3 Nov 2024 19:03:49 +0000 (20:03 +0100)] 
Fix underline bug in README

8 months agoMerge pull request #873 from esiaero/master 877/head
Eric Hawicz [Fri, 11 Oct 2024 00:55:18 +0000 (20:55 -0400)] 
Merge pull request #873 from esiaero/master

Correct year in changelog for 0.18 release

8 months agoCorrect year in changelog for 0.18 release 873/head
Evan Si [Thu, 10 Oct 2024 23:47:55 +0000 (23:47 +0000)] 
Correct year in changelog for 0.18 release

8 months agofix linkhash breaking -std=c89 872/head
Simon Sobisch [Mon, 7 Oct 2024 08:16:42 +0000 (08:16 +0000)] 
fix linkhash breaking -std=c89

making the definition of _LH_INLINE depending on __STDC_VERSION__, not on a specific compiler

9 months agoUpdate openssl command to work for newer versions of openssl.
Eric Hawicz [Sun, 15 Sep 2024 17:16:48 +0000 (13:16 -0400)] 
Update openssl command to work for newer versions of openssl.

9 months agoUpdate the master branch to version 0.18.99
Eric Hawicz [Sun, 15 Sep 2024 17:06:06 +0000 (13:06 -0400)] 
Update the master branch to version 0.18.99

9 months agoUpdate abi-check.sh to compare 0.16 and 0.18
Eric Haszlakiewicz [Sun, 15 Sep 2024 16:10:57 +0000 (16:10 +0000)] 
Update abi-check.sh to compare 0.16 and 0.18

9 months agoFix the expected output for test_parse
Eric Hawicz [Sun, 15 Sep 2024 15:59:05 +0000 (11:59 -0400)] 
Fix the expected output for test_parse

9 months agoUpdate ChangeLog, AUTHORS and issues_closed_for_0.18.md for an upcoming 0.18 release.
Eric Hawicz [Sun, 15 Sep 2024 15:46:56 +0000 (11:46 -0400)] 
Update ChangeLog, AUTHORS and issues_closed_for_0.18.md for an upcoming 0.18 release.

9 months agoMerge pull request #871 from json-c/disallow-control-chars
Eric Hawicz [Sun, 15 Sep 2024 15:22:58 +0000 (11:22 -0400)] 
Merge pull request #871 from json-c/disallow-control-chars

Issue #867: disallow control characters in strict mode.

9 months agoIssue #867: disallow control characters in strict mode. disallow-control-chars 871/head
Eric Hawicz [Mon, 2 Sep 2024 13:43:04 +0000 (09:43 -0400)] 
Issue #867: disallow control characters in strict mode.

10 months agoMerge pull request #864 from pavelzw/patch-1
Eric Hawicz [Fri, 30 Aug 2024 01:08:52 +0000 (21:08 -0400)] 
Merge pull request #864 from pavelzw/patch-1

Build pkg-config for msvc as well

10 months agoUpdate CMakeLists.txt 864/head
Pavel Zwerschke [Thu, 29 Aug 2024 08:55:02 +0000 (10:55 +0200)] 
Update CMakeLists.txt

12 months agoBuild pkg-config for msvc as well
Pavel Zwerschke [Mon, 17 Jun 2024 22:11:13 +0000 (00:11 +0200)] 
Build pkg-config for msvc as well

14 months agoMerge pull request #861 from bhaible/handle-another-oom-condition
Eric Hawicz [Sun, 5 May 2024 13:49:26 +0000 (09:49 -0400)] 
Merge pull request #861 from bhaible/handle-another-oom-condition

Handle yet another out-of-memory condition.

14 months agoAlthough CMAKE_C_COMPILER_FRONTEND_VARIANT is defined, it's not always set to some...
Eric Haszlakiewicz [Sun, 28 Apr 2024 17:15:42 +0000 (17:15 +0000)] 
Although CMAKE_C_COMPILER_FRONTEND_VARIANT is defined, it's not always set to some value.  Fix builds for cases when it's blank.

14 months agoHandle yet another out-of-memory condition. 861/head
Bruno Haible [Sun, 21 Apr 2024 23:50:59 +0000 (01:50 +0200)] 
Handle yet another out-of-memory condition.

duplocale() can return NULL, with errno set to ENOMEM.
In this case, bail out and set the current error code to
json_tokener_error_memory.

14 months agoIssue #857: fix a few places where json_tokener should have been returning json_token...
Eric Hawicz [Sun, 21 Apr 2024 14:37:16 +0000 (10:37 -0400)] 
Issue #857: fix a few places where json_tokener should have been returning json_tokener_error_memory but wasn't.

14 months agoMerge pull request #858 from alurm/master
Eric Hawicz [Tue, 16 Apr 2024 15:23:09 +0000 (11:23 -0400)] 
Merge pull request #858 from alurm/master

json_tokener.h: json_tokener_parse_verbose: fix typo

14 months agojson_tokener.h: json_tokener_parse_verbose: fix typo 858/head
Alan Urmancheev [Tue, 16 Apr 2024 14:56:00 +0000 (14:56 +0000)] 
json_tokener.h: json_tokener_parse_verbose: fix typo

15 months agoIssue #829: attempt to detect clang-cl.exe and pass MSVC-compatile command line argum...
Eric Hawicz [Sat, 30 Mar 2024 02:40:45 +0000 (22:40 -0400)] 
Issue #829: attempt to detect clang-cl.exe and pass MSVC-compatile command line arguments.

15 months agoIssue #850: fill in & adjust the "@returns" docs for several functions.
Eric Hawicz [Fri, 29 Mar 2024 22:46:05 +0000 (18:46 -0400)] 
Issue #850: fill in & adjust the "@returns" docs for several functions.

15 months agodoxygen can't handle html on heading, split that to separate lines
Eric Hawicz [Fri, 29 Mar 2024 22:45:22 +0000 (18:45 -0400)] 
doxygen can't handle html on heading, split that to separate lines
https://github.com/doxygen/doxygen/issues/10466

15 months agoFix issue #854: Set error=json_tokener_error_memory in json_tokener_parser_verbose...
Eric Hawicz [Fri, 29 Mar 2024 22:09:12 +0000 (18:09 -0400)] 
Fix issue #854: Set error=json_tokener_error_memory in json_tokener_parser_verbose() when allocating the tokener fails.

16 months agoMerge pull request #852 from fedefrancescon/docs/micro-typo-fix
Eric Hawicz [Sat, 2 Mar 2024 22:31:24 +0000 (17:31 -0500)] 
Merge pull request #852 from fedefrancescon/docs/micro-typo-fix

docs: micro typo in json_object_put doc

16 months agodocs: micro typo in json_object_get doc 852/head
Federico Francescon [Sat, 2 Mar 2024 21:41:10 +0000 (22:41 +0100)] 
docs: micro typo in json_object_get doc

16 months agoMerge pull request #831 from neheb/1
Eric Hawicz [Thu, 8 Feb 2024 13:11:57 +0000 (08:11 -0500)] 
Merge pull request #831 from neheb/1

rename WIN32 to _WIN32

16 months agorename WIN32 to _WIN32 831/head
Rosen Penev [Thu, 14 Sep 2023 03:51:49 +0000 (20:51 -0700)] 
rename WIN32 to _WIN32

The latter is the proper macro defined by Windows headers.

Fixes compilation under at least clang-cl which mandates function
declarations.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
17 months agoMerge pull request #849 from rouault/random_seed_toctou
Eric Hawicz [Mon, 8 Jan 2024 17:45:39 +0000 (12:45 -0500)] 
Merge pull request #849 from rouault/random_seed_toctou

random_seed.c: add a Coverity Scan suppression

17 months agorandom_seed.c: add a Coverity Scan suppression 849/head
Even Rouault [Sun, 7 Jan 2024 19:55:35 +0000 (20:55 +0100)] 
random_seed.c: add a Coverity Scan suppression

Coverity Scan warns about the use of open() after stat() being a
potential TOCTOU (Time of check time of use) issue. But here there is no
such issue.

18 months agoMerge pull request #846 from evo-i/CMP0153
Eric Hawicz [Sun, 17 Dec 2023 12:23:07 +0000 (07:23 -0500)] 
Merge pull request #846 from evo-i/CMP0153

Use execute_process instead of exec_program

18 months agoUpdate CMakeLists.txt 846/head
evo [Sun, 17 Dec 2023 08:19:20 +0000 (11:19 +0300)] 
Update CMakeLists.txt

Replace with `execute_process` available on v3.0+

18 months agoUpdate CMakeLists.txt
evo [Sat, 16 Dec 2023 21:32:21 +0000 (00:32 +0300)] 
Update CMakeLists.txt

Now saved to variable.

18 months agoFix ECHO_OUTPUT_VARIABLE
evo [Sat, 16 Dec 2023 21:23:51 +0000 (00:23 +0300)] 
Fix ECHO_OUTPUT_VARIABLE

18 months ago[CMP0153](https://cmake.org/cmake/help/latest/policy/CMP0153.html) 845/head
evo [Tue, 12 Dec 2023 13:28:41 +0000 (16:28 +0300)] 
[CMP0153](https://cmake.org/cmake/help/latest/policy/CMP0153.html)

19 months agoIssue #842 - fix one particular sign conversion warning.
Eric Haszlakiewicz [Thu, 30 Nov 2023 13:59:13 +0000 (13:59 +0000)] 
Issue #842 - fix one particular sign conversion warning.
There are many others that show up if we were to add -Wsign-conversions,
but this is the only one using a literal constant.

19 months agoMerge pull request #839 from ffontaine/master
Eric Hawicz [Wed, 8 Nov 2023 23:11:13 +0000 (18:11 -0500)] 
Merge pull request #839 from ffontaine/master

json_pointer.c: initialize idx

19 months agojson_pointer.c: initialize idx 839/head
Fabrice Fontaine [Wed, 8 Nov 2023 21:42:48 +0000 (22:42 +0100)] 
json_pointer.c: initialize idx

Fix the following build failure with gcc 5:

/home/thomas/autobuild/instance-2/output-1/build/json-c-0.17/json_pointer.c: In function 'json_pointer_result_get_recursive':
/home/thomas/autobuild/instance-2/output-1/build/json-c-0.17/json_pointer.c:193:25: error: 'idx' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    res->index_in_parent = idx;
                         ^

Fixes:
 - http://autobuild.buildroot.org/results/523b35a979d59121fe4e18c38171792b06233940/

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
20 months agoMerge pull request #837 from HansolChoe/fix-tokener-parse-ex-fuzzer
Eric Hawicz [Thu, 19 Oct 2023 11:49:32 +0000 (07:49 -0400)] 
Merge pull request #837 from HansolChoe/fix-tokener-parse-ex-fuzzer

Add type checking for parsed objects in tokener_parse_ex_fuzzer

20 months agotokener_parse_ex_fuzzer: add type checking for parsed object 837/head
HansolChoe [Thu, 19 Oct 2023 07:33:01 +0000 (16:33 +0900)] 
tokener_parse_ex_fuzzer: add type checking for parsed object

21 months agoTake 2 fixing the placement of json_tokener_error_memory in the enum. (json_tokener_...
Eric Hawicz [Sat, 23 Sep 2023 02:26:21 +0000 (22:26 -0400)] 
Take 2 fixing the placement of json_tokener_error_memory in the enum.  (json_tokener_error_size is an actual error, *not* a measure of the size of the enum!)

21 months agoMerge pull request #827 from robert-pang/master
Eric Hawicz [Sun, 10 Sep 2023 22:13:45 +0000 (00:13 +0200)] 
Merge pull request #827 from robert-pang/master

Resolve build issue in tokener_parse_ex_fuzzer.c

21 months agoMerge pull request #826 from emlix/cmake-policies
Eric Hawicz [Sun, 10 Sep 2023 22:10:55 +0000 (00:10 +0200)] 
Merge pull request #826 from emlix/cmake-policies

CMake: remove needless policy setting

22 months agoFix variable and API names in tokener_parse_ex_fuzzer.cc to resolve build issue. 827/head
Robert Pang [Tue, 5 Sep 2023 20:58:51 +0000 (13:58 -0700)] 
Fix variable and API names in tokener_parse_ex_fuzzer.cc to resolve build issue.

22 months agoCMake: request all policies up to CMake 3.12 being set to NEW 826/head
Rolf Eike Beer [Tue, 5 Sep 2023 12:31:24 +0000 (14:31 +0200)] 
CMake: request all policies up to CMake 3.12 being set to NEW

22 months agoCMake: request consistent minimum version
Rolf Eike Beer [Tue, 5 Sep 2023 12:27:27 +0000 (14:27 +0200)] 
CMake: request consistent minimum version

22 months agoCMake: remove needless policy setting
Rolf Eike Beer [Tue, 5 Sep 2023 10:14:46 +0000 (12:14 +0200)] 
CMake: remove needless policy setting

These policies were all introduced before CMake 3.9, so they will automatically
be initialized to the new behavior when requesting a minimum version of 3.9.

22 months agoUpdate the master branch to version 0.17.99
Eric Haszlakiewicz [Sat, 12 Aug 2023 19:08:59 +0000 (19:08 +0000)] 
Update the master branch to version 0.17.99

22 months agoAdd an abi-check.sh script that shows how to run the abi-compliance-checker, update...
Eric Hawicz [Sat, 12 Aug 2023 18:34:35 +0000 (14:34 -0400)] 
Add an abi-check.sh script that shows how to run the abi-compliance-checker, update release creation steps slightly.

22 months agoAlso fix messages returned from json_tokener_error_desc() (broke due to the ordering...
Eric Haszlakiewicz [Sat, 12 Aug 2023 18:52:32 +0000 (18:52 +0000)] 
Also fix messages returned from json_tokener_error_desc() (broke due to the ordering change of enum json_tokener_error)

22 months agoMove the json_tokener_error_memory entry to the end of enum json_tokener_error to...
Eric Hawicz [Sat, 12 Aug 2023 17:54:50 +0000 (13:54 -0400)] 
Move the json_tokener_error_memory entry to the end of enum json_tokener_error to restore binary compatibility with 0.16

22 months agoUpdate the AUTHORS file and add issues_closed_for_0.17.md for the upcoming 0.17 release
Eric Hawicz [Sat, 12 Aug 2023 17:53:27 +0000 (13:53 -0400)] 
Update the AUTHORS file and add issues_closed_for_0.17.md for the upcoming 0.17 release

22 months agoUpdate the ChangeLog for 0.17 based on notable commits since 0.16
Eric Hawicz [Tue, 8 Aug 2023 21:31:38 +0000 (17:31 -0400)] 
Update the ChangeLog for 0.17 based on notable commits since 0.16

23 months agoFix issue #823: add back json_number_chars, but only because it's part of the public...
Eric Hawicz [Sun, 6 Aug 2023 19:35:04 +0000 (15:35 -0400)] 
Fix issue #823: add back json_number_chars, but only because it's part of the public API.

23 months agoMerge pull request #679 from GitMensch/patch-1
Eric Hawicz [Sun, 6 Aug 2023 02:32:37 +0000 (22:32 -0400)] 
Merge pull request #679 from GitMensch/patch-1

Let json-c be used with obsolete compilers

23 months agoPR #679: add workaround for old compilers w/o stdint.h (i.e. VS2008 and earlier) 679/head
Eric Hawicz [Sun, 6 Aug 2023 02:11:30 +0000 (22:11 -0400)] 
PR #679: add workaround for old compilers w/o stdint.h (i.e. VS2008 and earlier)

23 months agoMerge pull request #822 from SSharshunov/master
Eric Hawicz [Fri, 4 Aug 2023 15:47:23 +0000 (11:47 -0400)] 
Merge pull request #822 from SSharshunov/master

Added option to disable app build

23 months agoAdded option to disable app build 822/head
Sergey Sharshunov [Fri, 4 Aug 2023 14:46:50 +0000 (19:46 +0500)] 
Added option to disable app build

23 months agoMerge pull request #702 from commodo/json_patch
Eric Hawicz [Tue, 1 Aug 2023 02:19:30 +0000 (22:19 -0400)] 
Merge pull request #702 from commodo/json_patch

json_patch: add first implementation only with patch application

23 months agoDon't export json_pointer_get_internal, move json_object_array_insert_idx and json_pa... 702/head
Eric Hawicz [Sun, 30 Jul 2023 01:45:16 +0000 (21:45 -0400)] 
Don't export json_pointer_get_internal, move json_object_array_insert_idx and json_patch_apply to the JSONC_0.17 section in json-c.sym

23 months agoWork around a somewhat misleading warning about "a function declaration without a...
Eric Hawicz [Sat, 29 Jul 2023 15:22:12 +0000 (11:22 -0400)] 
Work around a somewhat misleading warning about "a function declaration without a prototype is deprecated in all versions of C" in test1.c

23 months agoFix json_patch_apply handling of removing the whole document (i.e. "path":"").
Eric Hawicz [Sat, 29 Jul 2023 02:12:51 +0000 (22:12 -0400)] 
Fix json_patch_apply handling of removing the whole document (i.e. "path":"").
Enable all disabled tests, add a few more including some with null documents.

23 months agoAdjust the behavior of the args passed to json_patch_apply to make it easier to do...
Eric Hawicz [Thu, 27 Jul 2023 02:01:04 +0000 (22:01 -0400)] 
Adjust the behavior of the args passed to json_patch_apply to make it easier to do in place modifications, and add a struct json_patch_error to report more details on failures.

23 months agoFix an uninitialized memory access in json_pointer.
Eric Hawicz [Wed, 26 Jul 2023 22:15:07 +0000 (18:15 -0400)] 
Fix an uninitialized memory access in json_pointer.
Add comments describing when the fields of the internal struct json_pointer_get_result are valid.

23 months agoCreate a json_pointer_private.h and move a few things there, fix test warnings, note...
Eric Hawicz [Sun, 16 Jul 2023 14:48:20 +0000 (10:48 -0400)] 
Create a json_pointer_private.h and move a few things there, fix test warnings, note array_list_insert_idx is private.

23 months agotests: test_json_patch: add test suite for JSON patch
Alexandru Ardelean [Tue, 20 Apr 2021 12:47:18 +0000 (15:47 +0300)] 
tests: test_json_patch: add test suite for JSON patch

Essentially, this change adds the test cases from this repo:
   https://github.com/json-patch/json-patch-tests

Specifically:
   https://github.com/json-patch/json-patch-tests/blob/master/spec_tests.json
   https://github.com/json-patch/json-patch-tests/blob/master/tests.json

The files were taken at the date of this commit, at git hash
  ea3af85790cb72893d0676597814b7532019c24e

Some tests may not have an 'expected' or 'error' field. Those are ignored.
One test was disabled manually via "disabled_in_json_c", because it tries
an impossible test, i.e. to add 2 "op" fields in the same patch entry,
something which is impossible in a JSON object.

For the 'error' cases, right now we only test that an error happens.
Later, we can extend this to check the error codes.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agojson_patch: add first implementation only with patch application
Alexandru Ardelean [Sat, 24 Apr 2021 14:00:13 +0000 (17:00 +0300)] 
json_patch: add first implementation only with patch application

Initially I wanted to also do a function that generates the JSON patch from
two JSON documents, but even just applying the JSON patch was a bit of
work, especially when needing to satisfy all the test-cases.

This change defines all the operation in the RFC6902. The addition isn't
too big (for the json_patch_apply() function), as part of the heavy lifting
is also done by JSON pointer logic.

All the ops were tested with the test-cases defined at:
  https://github.com/json-patch/json-patch-tests

RFC6902: https://tools.ietf.org/html/rfc6902

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agojson_pointer: split json_pointer_set_with_array_cb()
Alexandru Ardelean [Fri, 23 Apr 2021 18:56:29 +0000 (21:56 +0300)] 
json_pointer: split json_pointer_set_with_array_cb()

JSON patch is a bit more clear on how some array operations should be
handled. Unfortunately, handling them on a case-by-case is a bit tricky
because it's difficult to satisfy properly an 'add' operating with a 'move'
operation and the basic json_pointer_set().

With json_pointer_set{f}() we use json_object_array_put_idx() to insert a
value at a certain index.

With JSON patch:
* for the 'add' operation, we need to insert a value at a given index,
  which means shifting existing values by one to the right
  - also, we cannot allow values to be inserted/added outside the bounds of
    the array
* a 'move' operation, is described as a 'remove' and then an 'add';
  for arrays this complicates things, because when we want to a move a
  value within the array, we have to remove it first (during which the size
  of the array is reduced by one); when the size of the array is reduced by
  one, we can't add it to the last position in the array (before the
  remove)

The only sane method to handle this (after a few considerations) is to
provide a callback to the function that does the final put/insert into
the array. That way, we can do some final checks where these are needed to
handle each corner-case.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agojson_pointer: move array out-of-bounds check outside of is_valid_index()
Alexandru Ardelean [Fri, 23 Apr 2021 18:19:49 +0000 (21:19 +0300)] 
json_pointer: move array out-of-bounds check outside of is_valid_index()

The out-of-bounds check is useful when trying to index/obtain a value from
an array.
However, when we set a value to a specific JSON pointer, we can allow
values that are outside the length of the current array.
The RFC6901 doc isn't clear on that aspect, and doing so is a bit more
in-line with how json_object_array_{put,insert}_idx() functions behave.

This changes the behavior of json_pointer_set{f}() because now a value can
be set anywhere in the array.

Also, added a test-case for this behavior change.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agojson_pointer: introduce json_pointer_get_internal() for internal usage
Alexandru Ardelean [Tue, 20 Apr 2021 13:23:47 +0000 (16:23 +0300)] 
json_pointer: introduce json_pointer_get_internal() for internal usage

For JSON patch, we require that we get access to the parent of a JSON
object as well in order to do some operations via the API.

For example, given the object:
{
  "foo": "bar",
  "array", [ 1, 2, 3]
}

Using JSON pointer with the path
 * '/foo' will return 'bar' of type string
 * '/array/0' will return '1', of type integer

The problem is, that if we do 'json_object_put()' on any of the objects
above, this will not detach them from the parent, because there is no
information back to the parent.

One way to fix this, is to introduce links back to the parent, and have
these links be made by 'json_object_array_{put,insert}_idx()' and
'json_object_object_add{_ex}()'[1].

[1] For json_object_object_add_ex() we would need to de-constify the second
parameter, as we need to change it's internal state when being added to a
parent object. It may break some applications, but who knows.

But, since this information is needed mostly for JSON patch, another way to
address this, is to also retrieve the parent of an object via JSON pointer
and use json_object_object_del() and json_object_array_del_idx() on the
object's parent.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agojson_pointer: convert index to size_t type
Alexandru Ardelean [Sat, 24 Apr 2021 14:06:17 +0000 (17:06 +0300)] 
json_pointer: convert index to size_t type

The index cannot be negative when parsing in is_valid_index(), because we
don't allow the '-' character in a string before we get to the strtol()
function.

So, might as well remove the negative check (for idx) in is_valid_index()
and convert it to size_t. That may allow for higher values for the index
(which can be insane, but some people may want to try it).

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agotests: test1: add test cases for json_object_array_insert_idx()
Alexandru Ardelean [Tue, 20 Apr 2021 13:07:26 +0000 (16:07 +0300)] 
tests: test1: add test cases for json_object_array_insert_idx()

This change adds a few test cases to test the behavior of the new
json_object_array_insert_idx() function, to make sure it behaves according
to specification in doc-string.

This test uses assert() vs the old method of comparing outputs.
This will cause the test to fail because the outputs won't match, since the
assert() will kick in.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agojson_object: introduce json_object_array_insert_idx() API function
Alexandru Ardelean [Fri, 16 Apr 2021 13:12:22 +0000 (16:12 +0300)] 
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>
23 months agojson_pointer: fix comments about printf() variants of set/get()
Alexandru Ardelean [Thu, 22 Apr 2021 08:19:07 +0000 (11:19 +0300)] 
json_pointer: fix comments about printf() variants of set/get()

These were wrong. Some details about the json_pointer_setf() &
json_pointer_getf() were added in the json_pointer_set() &
json_pointer_get() doc-strings.

This change removes them.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
23 months agoIssue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work...
Eric Hawicz [Sun, 30 Jul 2023 17:38:15 +0000 (13:38 -0400)] 
Issue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work around a bug in older versions of FreeBSD (<12.4).

23 months agoIssue #808: turn off -Wshorten-64-to-32 for clang builds (aka iOS builds) to workarou...
Eric Hawicz [Sun, 30 Jul 2023 15:38:01 +0000 (11:38 -0400)] 
Issue #808: turn off -Wshorten-64-to-32 for clang builds (aka iOS builds) to workaround "implicit conversion loses integer precision" warnings.

23 months agoMerge pull request #772 from cosmo-ray/color
Eric Hawicz [Thu, 13 Jul 2023 22:04:48 +0000 (18:04 -0400)] 
Merge pull request #772 from cosmo-ray/color

add JSON_C_TO_STRING_COLOR option