Commit Graph
24 Commits
Author SHA1 Message Date
huangwenbin 0e5a2d43f7 json_parse returned success when input ended while the tokener was
still waiting for more data, and also after read() failures.

Finalize the tokener at EOF with the terminating NUL so valid scalar
values can complete, while rejecting genuinely truncated input.

Also propagate read errors to the caller and add CLI regression tests.
2026-09-14 15:23:04 +08:00
Eric Hawicz 694b912496 Merge pull request #970 from hilbert149/parseit
json_parse: Exit with error when reading the input fails
2026-09-12 09:39:00 -04:00
panzhe ea23279b75 json_parse: Exit with error when reading the input fails 2026-09-09 11:52:42 +08:00
panzhe 6c57831f03 Fix json_parse:exit with error when input file cannot be opened 2026-09-07 15:15:32 +08:00
Eric Hawicz d9d8cab822 Add tests for the json_parse cli tool. 2026-06-21 13:44:59 -04:00
Eric Hawicz 1d658982e5 Issue #929: fix bad calculation of error offset when parsing in the apps/json_parse tool.
Also, show the failing character in hex to ensure error output is readable.
2026-06-21 12:43:20 -04:00
Lakshmi-Surekha a7b34a299b apps: use CMake check for getopt.h
Add CMake detection for getopt.h and update json_parse.c to include it
only when HAVE_GETOPT_H is defined. Fixes AIX build failure.
2025-11-29 01:32:10 -06:00
Tyler Erickson 0883c24130 Merge branch 'json-c:master' into meson_support 2025-10-27 12:13:23 -06:00
Tyler Erickson e3a33ae8ae make: Adding support for building json-c with meson
Adding meson build files for json-c that work similarly to the cmake build files.
Where it made sense, I reused existing cmake .h.in files or generated entirely from meson.
All tests were done with GCC and Clang in ubuntu 24.04, Windows using MSVC 2022 and Clang-cl from llvm's repo using version 21.1.3

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
2025-10-20 12:08:01 -06:00
Guilhem Saurel 8af05ab785 CMake: sync minimum version 2025-08-06 22:10:41 +02:00
Eric Hawicz bf92456789 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. 2025-07-08 21:04:00 -04:00
Eric Hawicz 474ee12435 Fix the apps/json_parse "-s" (strict) option so it actually does something, and default to non-strict. 2024-11-03 19:44:21 -05: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
Eric Hawicz 11311ed2a3 Fix the -f option to apps/json_parse, add a -F <arg> option to specify arbitrary flags to pass to json_object_to_json_string_ext(). 2023-07-04 12:00:31 -04:00
Eric Haszlakiewicz bdd5e03d6e Apply some of the fixes from PR #740, although by using size_t instead of castings. 2022-07-31 19:28:48 +00:00
Eric Haszlakiewicz 6ee0a35a20 Fix #771/#768 by marking usage() as "noreturn" instead of using "FALLTHRU" in the case statement where it'd called. 2022-06-13 01:02:53 +00:00
An7ar35 5d00384e0d missing 'FALLTHRU' added to sort out error messages when using "-Werror=implicit-fallthrough" flag 2022-06-01 12:36:33 +02:00
Eric Haszlakiewicz 6ba1adf8ef Include the tests and apps directories at the _end_, since order in the
cmake rules matters, and fix compile warnings now that we're building
those sources with all the regular flags.
2022-05-30 14:33:16 +00:00
Marc 4e9e44e525 Fix read past end of buffer
Resolves https://github.com/json-c/json-c/issues/654
2020-08-07 10:49:45 +01:00
Eric Hawicz 45b6416652 Merge branch 'master' of https://github.com/json-c/json-c 2020-05-08 22:25:15 -04:00
Pierce Lopez 090ae4e4d4 json_parse demo: fix and use usage() function 2020-05-08 18:27:35 -04:00
Eric Hawicz 9b64c3e347 Fix printf format issues in apps/json_parse, and actually call the usage() function. 2020-05-03 14:55:12 -04:00
Eric Haszlakiewicz d9981f67dd Extend the CMakeLists.txt in the apps directory to be usable as a standalone build, to link against other versions of json-c.
Tweak json_parse.c slightly to allow it to build against older json-c versions.
2020-04-26 04:02:36 +00:00
Eric Haszlakiewicz 55d053118e Add an apps directory, and a json_parse program to parse an input file and report on memory usage.
This is intended to provide a way, during development, to test out the memory
and performance impacts of a change.
2020-04-21 03:57:56 +00:00