Skip to content

Commit 59e812d

Browse files
authored
Merge branch 'master' into bump-to-1.9.7.1
2 parents 7474178 + 3455302 commit 59e812d

18 files changed

Lines changed: 245 additions & 137 deletions

BUILD.bazel

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
licenses(["unencumbered"]) # Public Domain or MIT
2-
31
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
4+
licenses(["unencumbered"]) # Public Domain or MIT
45

56
exports_files(["LICENSE"])
67

@@ -36,9 +37,9 @@ cc_library(
3637
"include/json/allocator.h",
3738
"include/json/assertions.h",
3839
"include/json/config.h",
39-
"include/json/json_features.h",
4040
"include/json/forwards.h",
4141
"include/json/json.h",
42+
"include/json/json_features.h",
4243
"include/json/reader.h",
4344
"include/json/value.h",
4445
"include/json/version.h",

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# CMake versions greater than the JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION policies will
1313
# continue to generate policy warnings "CMake Warning (dev)...Policy CMP0XXX is not set:"
1414
#
15-
set(JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.8.0")
15+
set(JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION "3.10.0")
1616
set(JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION "3.13.2")
1717
cmake_minimum_required(VERSION ${JSONCPP_OLDEST_VALIDATED_POLICIES_VERSION})
1818
if("${CMAKE_VERSION}" VERSION_LESS "${JSONCPP_NEWEST_VALIDATED_POLICIES_VERSION}")
@@ -40,12 +40,6 @@ foreach(pold "") # Currently Empty
4040
endif()
4141
endforeach()
4242

43-
# Build the library with C++11 standard support, independent from other including
44-
# software which may use a different CXX_STANDARD or CMAKE_CXX_STANDARD.
45-
set(CMAKE_CXX_STANDARD 11)
46-
set(CMAKE_CXX_EXTENSIONS OFF)
47-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
48-
4943
# Ensure that CMAKE_BUILD_TYPE has a value specified for single configuration generators.
5044
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
5145
set(CMAKE_BUILD_TYPE Release CACHE STRING
@@ -79,6 +73,7 @@ option(JSONCPP_WITH_STRICT_ISO "Issue all the warnings demanded by strict ISO C
7973
option(JSONCPP_WITH_PKGCONFIG_SUPPORT "Generate and install .pc files" ON)
8074
option(JSONCPP_WITH_CMAKE_PACKAGE "Generate and install cmake package files" ON)
8175
option(JSONCPP_WITH_EXAMPLE "Compile JsonCpp example" OFF)
76+
option(JSONCPP_WITH_INSTALL "Include JsonCpp header and binaries in the install target" ON)
8277
option(JSONCPP_STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF)
8378
option(BUILD_SHARED_LIBS "Build jsoncpp_lib as a shared library." ON)
8479
option(BUILD_STATIC_LIBS "Build jsoncpp_lib as a static library." ON)

MODULE.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@ bazel_dep(
1717
name = "bazel_skylib",
1818
version = "1.7.1",
1919
)
20+
bazel_dep(
21+
name = "rules_cc",
22+
version = "0.0.17",
23+
)
24+
bazel_dep(
25+
name = "rules_python",
26+
version = "1.0.0",
27+
)

README.md

Lines changed: 49 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,121 +16,89 @@ serialization and deserialization to and from strings. It can also preserve
1616
existing comment in deserialization/serialization steps, making it a convenient
1717
format to store user input files.
1818

19-
## Documentation
19+
## Project Status
2020

21-
[JsonCpp documentation][JsonCpp-documentation] is generated using [Doxygen][].
21+
JsonCpp is a mature project in maintenance mode. Our priority is providing a stable,
22+
reliable JSON library for the long tail of C++ development.
2223

23-
[JsonCpp-documentation]: http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html
24-
[Doxygen]: http://www.doxygen.org
24+
### Current Focus
2525

26-
## A note on backward-compatibility
26+
* **Security:** Addressing vulnerabilities and fuzzing results.
27+
* **Compatibility:** Ensuring the library builds without warnings on the latest versions of GCC,
28+
Clang, and MSVC.
29+
* **Reliability:** Fixing regressions and critical logical bugs.
2730

28-
* `1.y.z` is built with C++11.
29-
* `0.y.z` can be used with older compilers.
30-
* `00.11.z` can be used both in old and new compilers.
31-
* Major versions maintain binary-compatibility.
31+
### Out of Scope
3232

33-
### Special note
33+
* **Performance:** We are not competing with SIMD-accelerated or reflection-based parsers.
34+
* **Features:** We are generally not accepting requests for new data formats or major API changes.
3435

35-
The branch `00.11.z`is a new branch, its major version number `00` is to show
36-
that it is different from `0.y.z` and `1.y.z`, the main purpose of this branch
37-
is to make a balance between the other two branches. Thus, users can use some
38-
new features in this new branch that introduced in 1.y.z, but can hardly applied
39-
into 0.y.z.
36+
JsonCpp remains a primary choice for developers who require comment preservation and support for
37+
legacy toolchains where modern C++ standards are unavailable. The library is intended to be a
38+
reliable dependency that does not require frequent updates or major migration efforts.
4039

41-
## Using JsonCpp in your project
40+
## A note on backward-compatibility
4241

43-
### The vcpkg dependency manager
42+
* **`1.y.z` (master):** Actively maintained. Requires C++11.
4443

45-
You can download and install JsonCpp using the [vcpkg](https://github.com/Microsoft/vcpkg/)
46-
dependency manager, which has installation instruction dependent on your
47-
build system. For example, if you are in a CMake project, the
48-
[CMake install tutorial](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-powershell)
49-
suggests the follow installation method.
44+
* **`0.y.z`:** Legacy support for pre-C++11 compilers. Maintenance is limited to critical security fixes.
5045

51-
First, clone and set up `vcpkg`.
46+
* **`00.11.z`:** Discontinued.
5247

53-
```sh
54-
git clone https://github.com/Microsoft/vcpkg.git
55-
cd vcpkg
56-
./bootstrap-vcpkg.sh
57-
```
48+
Major versions maintain binary compatibility. Critical security fixes are accepted for both the `master` and `0.y.z` branches.
5849

59-
Then, create a [vcpkg.json manifest](https://learn.microsoft.com/en-us/vcpkg/reference/vcpkg-json),
60-
enabling manifest mode and adding JsonCpp to the manifest's dependencies list.
50+
## Integration
6151

62-
```sh
63-
vcpkg new --application
64-
vcpkg add port jsoncpp
65-
```
66-
67-
> [!NOTE]: you can use vcpkg in either classic mode or manifest mode (recommended).
68-
69-
#### Classic mode
52+
> [!NOTE]
53+
> Package manager ports (vcpkg, Conan, etc.) are community-maintained. Please report outdated versions or missing generators to their respective repositories.
7054
71-
If your project does not have a `vcpkg.json`,
72-
your project is in [Classic mode](https://learn.microsoft.com/en-us/vcpkg/concepts/classic-mode)
73-
you can install JsonCpp by directly invoking the `install` command:
55+
### vcpkg
56+
Add `jsoncpp` to your `vcpkg.json` manifest:
7457

75-
```sh
76-
vcpkg install jsoncpp
58+
```json
59+
{
60+
"dependencies": ["jsoncpp"]
61+
}
7762
```
7863

79-
### Manifest mode
64+
Or install via classic mode: `vcpkg install jsoncpp`.
8065

81-
If your project *does* have a vcpkg.json manifest, your project is in [Manifest mode](https://learn.microsoft.com/en-us/vcpkg/concepts/manifest-mode)
82-
and you need to add JsonCpp to your package manifest dependencies, then invoke
83-
install with no arguments.
66+
### Conan
8467

8568
```sh
86-
vcpkg add port jsoncpp
87-
vcpkg install
69+
conan install --requires="jsoncpp/[*]" --build=missing
8870
```
8971

90-
Example manifest:
91-
92-
```sh
93-
{
94-
"name": "best-app-ever",
95-
"dependencies": [ "jsoncpp" ],
96-
}
97-
```
72+
If you are using a `conanfile.txt` in a Conan 2 project, ensure you use the appropriate generators:
9873

99-
> [!NOTE] The JsonCpp port in vcpkg is kept up to date by Microsoft team members and community contributors.
100-
> If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg)
101-
> on the vcpkg repository.
74+
```ini
75+
[requires]
76+
jsoncpp/[*]
10277

103-
### Conan package manager
78+
[generators]
79+
CMakeToolchain
80+
CMakeDeps
81+
```
10482

105-
You can download and install JsonCpp using the [Conan](https://conan.io/)
106-
package manager:
83+
### Meson
10784

10885
```sh
109-
conan install -r conancenter --requires="jsoncpp/[*]" --build=missing
86+
meson wrap install jsoncpp
11087
```
11188

112-
The JsonCpp package in Conan Center is kept up to date by [ConanCenterIndex](https://github.com/conan-io/conan-center-index)
113-
contributors. If the version is out of date, please create an issue or pull request on the
114-
Conan Center Index repository.
115-
11689
### Amalgamated source
11790

118-
See the [Wiki entry on Amalgamated Source](https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated-(Possibly-outdated)).
91+
> [!NOTE]
92+
> This approach may be outdated.
11993
120-
### The Meson Build System
94+
For projects requiring a single-header approach, see the [Wiki entry](https://github.com/open-source-parsers/jsoncpp/wiki/Amalgamated-(Possibly-outdated)).
12195

122-
If you are using the [Meson Build System](http://mesonbuild.com), then you can
123-
get a wrap file by downloading it from [Meson WrapDB](https://mesonbuild.com/Wrapdb-projects.html),
124-
or simply use `meson wrap install jsoncpp`.
125-
126-
### Other ways
96+
## Documentation
12797

128-
If you have trouble, see the
129-
[Wiki](https://github.com/open-source-parsers/jsoncpp/wiki), or post a question
130-
as an Issue.
98+
Documentation is generated via [Doxygen](http://open-source-parsers.github.io/jsoncpp-docs/doxygen/index.html).
99+
Additional information is available on the [Project Wiki](https://github.com/open-source-parsers/jsoncpp/wiki).
131100

132101
## License
133102

134-
See the [LICENSE](./LICENSE) file for details. In summary, JsonCpp is licensed
135-
under the MIT license, or public domain if desired and recognized in your
136-
jurisdiction.
103+
JsonCpp is licensed under the MIT license, or public domain where recognized.
104+
See [LICENSE](./LICENSE) for details.

example/BUILD.bazel

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
13
cc_binary(
24
name = "readFromStream_ok",
35
srcs = ["readFromStream/readFromStream.cpp"],
4-
deps = ["//:jsoncpp"],
56
args = ["$(location :readFromStream/withComment.json)"],
67
data = ["readFromStream/withComment.json"],
8+
deps = ["//:jsoncpp"],
79
)
810

911
cc_binary(
1012
name = "readFromStream_err",
1113
srcs = ["readFromStream/readFromStream.cpp"],
12-
deps = ["//:jsoncpp"],
1314
args = ["$(location :readFromStream/errorFormat.json)"],
1415
data = ["readFromStream/errorFormat.json"],
16+
deps = ["//:jsoncpp"],
1517
)
1618

1719
cc_binary(

include/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
if (JSONCPP_WITH_INSTALL)
2+
13
file(GLOB INCLUDE_FILES "json/*.h")
24
install(FILES
35
${INCLUDE_FILES}
46
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json)
57

8+
endif()

include/json/reader.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ class JSON_API Reader {
8181
* document.
8282
*
8383
* \param beginDoc Pointer on the beginning of the UTF-8 encoded
84-
* string of the document to read.
84+
* string of the document to read. The pointed-to
85+
* buffer must outlive this Reader if error
86+
* methods (e.g. getFormattedErrorMessages()) are
87+
* called after parse() returns.
8588
* \param endDoc Pointer on the end of the UTF-8 encoded string
8689
* of the document to read. Must be >= beginDoc.
8790
* \param[out] root Contains the root value of the document if it

include/json/value.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@
3939
#endif
4040
#endif
4141

42+
#ifndef JSONCPP_HAS_STRING_VIEW
4243
#if __cplusplus >= 201703L
4344
#define JSONCPP_HAS_STRING_VIEW 1
4445
#endif
46+
#endif
4547

4648
#include <array>
4749
#include <exception>
@@ -50,6 +52,9 @@
5052
#include <string>
5153
#include <vector>
5254

55+
// Forward declaration for testing.
56+
struct ValueTest;
57+
5358
#ifdef JSONCPP_HAS_STRING_VIEW
5459
#include <string_view>
5560
#endif
@@ -201,6 +206,7 @@ class JSON_API StaticString {
201206
*/
202207
class JSON_API Value {
203208
friend class ValueIteratorBase;
209+
friend struct ::ValueTest;
204210

205211
public:
206212
using Members = std::vector<String>;
@@ -266,7 +272,7 @@ class JSON_API Value {
266272
private:
267273
#endif
268274
#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
269-
class CZString {
275+
class JSON_API CZString {
270276
public:
271277
enum DuplicationPolicy { noDuplication = 0, duplicate, duplicateOnCopy };
272278
CZString(ArrayIndex index);

src/jsontestrunner/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
13
cc_binary(
24
name = "jsontestrunner",
35
srcs = ["main.cpp"],
4-
deps = ["//:jsoncpp"],
56
visibility = ["//test:__pkg__"],
7+
deps = ["//:jsoncpp"],
68
)

src/jsontestrunner/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ if(PYTHONINTERP_FOUND)
4848
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data"
4949
WORKING_DIRECTORY "${TEST_DIR}/data"
5050
)
51+
52+
# Both tests write .actual/.actual-rewrite along with test data, need to prevent collision when running tests via ctest -j
53+
set_tests_properties(jsoncpp_readerwriter jsoncpp_readerwriter_json_checker
54+
PROPERTIES RESOURCE_LOCK "test_data_files"
55+
)
5156
endif()

0 commit comments

Comments
 (0)