]> git.ipfire.org Git - thirdparty/json-c.git/log
thirdparty/json-c.git
6 weeks agoMerge pull request #898 from Seagate/fix_cmake_clangcl
Eric Hawicz [Sat, 25 Oct 2025 13:46:22 +0000 (09:46 -0400)] 
Merge pull request #898 from Seagate/fix_cmake_clangcl

bug: Fixing Cmake build when using clang-cl

6 weeks agoMerge pull request #895 from nim65s/patch-1
Eric Hawicz [Sat, 25 Oct 2025 13:45:50 +0000 (09:45 -0400)] 
Merge pull request #895 from nim65s/patch-1

CMake: sync minimum version

6 weeks agobug: Fixing Cmake build when using clang-cl 898/head
Tyler Erickson [Mon, 20 Oct 2025 17:39:04 +0000 (11:39 -0600)] 
bug: Fixing Cmake build when using clang-cl

Clang-cl will fail to build and produce warnings about redefining existing symbols, mostly for float.h and math.h compatibility.

To resolve this, this moves the clang-cl detection earlier in the CMakeLists.txt so that CLANG_CL can be checked properly where there is an existing MSVC workaround for these symbols.
This resolves the build using the latest clang-cl from the LLVM clang repo as well as clang-cl that can be installed with MSVC 2022.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
4 months agoMerge pull request #893 from sffc/supplemental-code-point-bug
Eric Hawicz [Thu, 7 Aug 2025 13:46:47 +0000 (09:46 -0400)] 
Merge pull request #893 from sffc/supplemental-code-point-bug

Fix bug involving supplemental code points that look like high surrogates

4 months agoCMake: sync minimum version 895/head
Guilhem Saurel [Wed, 6 Aug 2025 20:09:34 +0000 (22:09 +0200)] 
CMake: sync minimum version

4 months agoFix code and update tests 893/head
Shane F. Carr [Thu, 31 Jul 2025 00:40:56 +0000 (17:40 -0700)] 
Fix code and update tests

4 months agoAdd tests with current behavior
Shane F. Carr [Thu, 31 Jul 2025 00:39:47 +0000 (17:39 -0700)] 
Add tests with current behavior

5 months agoMake json_parse a bit more useful by adding -u (validate UTF8) and -P (specify arbitr...
Eric Hawicz [Wed, 9 Jul 2025 01:02:52 +0000 (21:02 -0400)] 
Make json_parse a bit more useful by adding -u (validate UTF8) and -P (specify arbitrary tokener parse flags), and read from stdin if no filename is provided.

8 months agoIssue #867 - also disallow control characters in keys
Eric Hawicz [Fri, 4 Apr 2025 01:09:05 +0000 (21:09 -0400)] 
Issue #867 - also disallow control characters in keys

10 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

11 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)

11 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

11 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

11 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

11 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

11 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

11 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

11 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

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

11 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

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

12 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

12 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.

12 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`.

12 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

12 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

12 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.

12 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

12 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.

13 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>
13 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.

13 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

13 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

13 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

14 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

14 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.

14 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

14 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

14 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

14 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.

14 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.

14 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.

15 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

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

17 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

19 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.

19 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.

19 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.

19 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.

19 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

19 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

20 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.

20 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.

20 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

20 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.

21 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

21 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

22 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

22 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>
23 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

23 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.

23 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

23 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+

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

Now saved to variable.

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

23 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)

2 years 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.

2 years 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

2 years 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>
2 years 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

2 years 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

2 years 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!)

2 years 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

2 years 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

2 years 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.

2 years 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

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

2 years 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.

2 years 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

2 years 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.

2 years 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)

2 years 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

2 years 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

2 years 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

2 years 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.

2 years 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

2 years 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)

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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.

2 years 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.

2 years 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.

2 years 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.

2 years 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>
2 years 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>
2 years 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>
2 years 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>