Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
041af50512 | ||
|
|
934b12a9e1 |
No files matched your search
@@ -1383,7 +1383,6 @@ Use your favorite [**package manager**](https://json.nlohmann.me/integration/pac
|
|||||||
- [**build2**](https://json.nlohmann.me/integration/package_managers/#build2) `nlohmann-json`
|
- [**build2**](https://json.nlohmann.me/integration/package_managers/#build2) `nlohmann-json`
|
||||||
- <img src="https://raw.githubusercontent.com/nlohmann/json/refs/heads/develop/docs/mkdocs/docs/images/package_managers/CPM.png" height="20"> [**cpm.cmake**](https://json.nlohmann.me/integration/package_managers/#cpmcmake) `gh:nlohmann/json`
|
- <img src="https://raw.githubusercontent.com/nlohmann/json/refs/heads/develop/docs/mkdocs/docs/images/package_managers/CPM.png" height="20"> [**cpm.cmake**](https://json.nlohmann.me/integration/package_managers/#cpmcmake) `gh:nlohmann/json`
|
||||||
- <img src="https://raw.githubusercontent.com/nlohmann/json/refs/heads/develop/docs/mkdocs/docs/images/package_managers/xmake.svg" height="20"> [**xmake**](https://json.nlohmann.me/integration/package_managers/#xmake) `nlohmann_json`
|
- <img src="https://raw.githubusercontent.com/nlohmann/json/refs/heads/develop/docs/mkdocs/docs/images/package_managers/xmake.svg" height="20"> [**xmake**](https://json.nlohmann.me/integration/package_managers/#xmake) `nlohmann_json`
|
||||||
- <img src="https://raw.githubusercontent.com/nlohmann/json/refs/heads/develop/docs/mkdocs/docs/images/package_managers/nix.svg" height="20"> [**Nix**](https://json.nlohmann.me/integration/package_managers/#nix) `nlohmann_json`
|
|
||||||
|
|
||||||
The library is part of many package managers. See the [**documentation**](https://json.nlohmann.me/integration/package_managers/) for detailed descriptions and examples.
|
The library is part of many package managers. See the [**documentation**](https://json.nlohmann.me/integration/package_managers/) for detailed descriptions and examples.
|
||||||
|
|
||||||
|
|||||||
@@ -1,187 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="535"
|
|
||||||
height="535"
|
|
||||||
viewBox="0 0 501.56251 501.56249"
|
|
||||||
id="svg2"
|
|
||||||
version="1.1"
|
|
||||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
|
|
||||||
sodipodi:docname="nix-snowflake-colours.svg"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
|
||||||
<defs
|
|
||||||
id="defs4">
|
|
||||||
<linearGradient
|
|
||||||
inkscape:collect="always"
|
|
||||||
id="linearGradient5562">
|
|
||||||
<stop
|
|
||||||
style="stop-color:#699ad7;stop-opacity:1"
|
|
||||||
offset="0"
|
|
||||||
id="stop5564" />
|
|
||||||
<stop
|
|
||||||
id="stop5566"
|
|
||||||
offset="0.24345198"
|
|
||||||
style="stop-color:#7eb1dd;stop-opacity:1" />
|
|
||||||
<stop
|
|
||||||
style="stop-color:#7ebae4;stop-opacity:1"
|
|
||||||
offset="1"
|
|
||||||
id="stop5568" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
inkscape:collect="always"
|
|
||||||
id="linearGradient5053">
|
|
||||||
<stop
|
|
||||||
style="stop-color:#415e9a;stop-opacity:1"
|
|
||||||
offset="0"
|
|
||||||
id="stop5055" />
|
|
||||||
<stop
|
|
||||||
id="stop5057"
|
|
||||||
offset="0.23168644"
|
|
||||||
style="stop-color:#4a6baf;stop-opacity:1" />
|
|
||||||
<stop
|
|
||||||
style="stop-color:#5277c3;stop-opacity:1"
|
|
||||||
offset="1"
|
|
||||||
id="stop5059" />
|
|
||||||
</linearGradient>
|
|
||||||
<linearGradient
|
|
||||||
inkscape:collect="always"
|
|
||||||
xlink:href="#linearGradient5562"
|
|
||||||
id="linearGradient4328"
|
|
||||||
gradientUnits="userSpaceOnUse"
|
|
||||||
gradientTransform="translate(70.650339,-1055.1511)"
|
|
||||||
x1="200.59668"
|
|
||||||
y1="351.41116"
|
|
||||||
x2="290.08701"
|
|
||||||
y2="506.18814" />
|
|
||||||
<linearGradient
|
|
||||||
inkscape:collect="always"
|
|
||||||
xlink:href="#linearGradient5053"
|
|
||||||
id="linearGradient4330"
|
|
||||||
gradientUnits="userSpaceOnUse"
|
|
||||||
gradientTransform="translate(864.69589,-1491.3405)"
|
|
||||||
x1="-584.19934"
|
|
||||||
y1="782.33563"
|
|
||||||
x2="-496.29703"
|
|
||||||
y2="937.71399" />
|
|
||||||
</defs>
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="base"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1.0"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:zoom="0.70904368"
|
|
||||||
inkscape:cx="99.429699"
|
|
||||||
inkscape:cy="195.33352"
|
|
||||||
inkscape:document-units="px"
|
|
||||||
inkscape:current-layer="layer3"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1050"
|
|
||||||
inkscape:window-x="1920"
|
|
||||||
inkscape:window-y="30"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:snap-global="true"
|
|
||||||
fit-margin-top="0"
|
|
||||||
fit-margin-left="0"
|
|
||||||
fit-margin-right="0"
|
|
||||||
fit-margin-bottom="0"
|
|
||||||
inkscape:showpageshadow="2"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#d1d1d1" />
|
|
||||||
<metadata
|
|
||||||
id="metadata7">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer3"
|
|
||||||
inkscape:label="gradient-logo"
|
|
||||||
style="display:inline;opacity:1"
|
|
||||||
transform="translate(-156.41121,933.30685)">
|
|
||||||
<g
|
|
||||||
id="g2"
|
|
||||||
transform="matrix(0.99994059,0,0,0.99994059,-0.06321798,33.188377)"
|
|
||||||
style="stroke-width:1.00006">
|
|
||||||
<path
|
|
||||||
sodipodi:nodetypes="cccccccccc"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
id="path3336-6"
|
|
||||||
d="m 309.54892,-710.38827 122.19683,211.67512 -56.15706,0.5268 -32.6236,-56.8692 -32.85645,56.5653 -27.90237,-0.011 -14.29086,-24.6896 46.81047,-80.4901 -33.22946,-57.8257 z"
|
|
||||||
style="opacity:1;fill:url(#linearGradient4328);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.00018;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<use
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
transform="rotate(60,407.11155,-715.78724)"
|
|
||||||
id="use3439-6"
|
|
||||||
inkscape:transform-center-y="151.59082"
|
|
||||||
inkscape:transform-center-x="124.43045"
|
|
||||||
xlink:href="#path3336-6"
|
|
||||||
y="0"
|
|
||||||
x="0"
|
|
||||||
style="stroke-width:1.00006" />
|
|
||||||
<use
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
transform="rotate(-60,407.31177,-715.70016)"
|
|
||||||
id="use3445-0"
|
|
||||||
inkscape:transform-center-y="75.573958"
|
|
||||||
inkscape:transform-center-x="-168.20651"
|
|
||||||
xlink:href="#path3336-6"
|
|
||||||
y="0"
|
|
||||||
x="0"
|
|
||||||
style="stroke-width:1.00006" />
|
|
||||||
<use
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
transform="rotate(180,407.41868,-715.7565)"
|
|
||||||
id="use3449-5"
|
|
||||||
inkscape:transform-center-y="-139.94592"
|
|
||||||
inkscape:transform-center-x="59.669705"
|
|
||||||
xlink:href="#path3336-6"
|
|
||||||
y="0"
|
|
||||||
x="0"
|
|
||||||
style="stroke-width:1.00006" />
|
|
||||||
<path
|
|
||||||
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#linearGradient4330);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:3.00018;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
|
|
||||||
d="m 309.54892,-710.38827 122.19683,211.67512 -56.15706,0.5268 -32.6236,-56.8692 -32.85645,56.5653 -27.90237,-0.011 -14.29086,-24.6896 46.81047,-80.4901 -33.22946,-57.8256 z"
|
|
||||||
id="path4260-0"
|
|
||||||
inkscape:connector-curvature="0"
|
|
||||||
sodipodi:nodetypes="cccccccccc" />
|
|
||||||
<use
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
transform="rotate(120,407.33916,-716.08356)"
|
|
||||||
id="use4354-5"
|
|
||||||
xlink:href="#path4260-0"
|
|
||||||
y="0"
|
|
||||||
x="0"
|
|
||||||
style="display:inline;stroke-width:1.00006" />
|
|
||||||
<use
|
|
||||||
height="100%"
|
|
||||||
width="100%"
|
|
||||||
transform="rotate(-120,407.28823,-715.86995)"
|
|
||||||
id="use4362-2"
|
|
||||||
xlink:href="#path4260-0"
|
|
||||||
y="0"
|
|
||||||
x="0"
|
|
||||||
style="display:inline;stroke-width:1.00006" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 6.4 KiB |
@@ -1,7 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
|
||||||
project(json_example)
|
|
||||||
|
|
||||||
find_package(nlohmann_json CONFIG REQUIRED)
|
|
||||||
|
|
||||||
add_executable(json_example example.cpp)
|
|
||||||
target_link_libraries(json_example PRIVATE nlohmann_json::nlohmann_json)
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#include <nlohmann/json.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
using nlohmann::json;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::cout << std::setw(4) << json::meta() << std::endl;
|
|
||||||
}
|
|
||||||
@@ -14,8 +14,7 @@
|
|||||||
{: style="height:1em"} [**Conda**](#conda) `nlohmann_json`  
|
{: style="height:1em"} [**Conda**](#conda) `nlohmann_json`  
|
||||||
{: style="height:1em"} [**MacPorts**](#macports) `nlohmann-json`<br>
|
{: style="height:1em"} [**MacPorts**](#macports) `nlohmann-json`<br>
|
||||||
{: style="height:1em"} [**CPM.cmake**](#cpmcmake) `gh:nlohmann/json`  
|
{: style="height:1em"} [**CPM.cmake**](#cpmcmake) `gh:nlohmann/json`  
|
||||||
{: style="height:1em"} [**xmake**](#xmake) `nlohmann_json`  
|
{: style="height:1em"} [**xmake**](#xmake) `nlohmann_json`
|
||||||
{: style="height:1em"} [**Nix**](#nix) `nlohmann_json`
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Running example
|
## Running example
|
||||||
@@ -907,56 +906,6 @@ CPMAddPackage("gh:nlohmann/json@3.12.0")
|
|||||||
|
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
## Nix
|
|
||||||
|
|
||||||
!!! abstract "Summary"
|
|
||||||
|
|
||||||
package: [**`nlohmann_json`**](https://search.nixos.org/packages?channel=unstable&show=nlohmann_json&query=nlohmann_json)
|
|
||||||
|
|
||||||
- :octicons-tag-24: Available versions: current version of each Nixpkgs channel (may lag behind the latest release)
|
|
||||||
- :octicons-rocket-24: The package is maintained by the Nixpkgs community and updated after releases.
|
|
||||||
- :octicons-file-24: File issues at the [Nixpkgs issue tracker](https://github.com/NixOS/nixpkgs/issues)
|
|
||||||
- :octicons-question-24: [Nix website](https://nixos.org)
|
|
||||||
|
|
||||||
If you are using [Nix](https://nixos.org) or [NixOS](https://nixos.org/manual/nixos/stable/), the library is available
|
|
||||||
as the [nlohmann_json](https://search.nixos.org/packages?channel=unstable&show=nlohmann_json&query=nlohmann_json)
|
|
||||||
package in [Nixpkgs](https://github.com/NixOS/nixpkgs). To try it in a temporary shell, execute
|
|
||||||
|
|
||||||
```shell
|
|
||||||
nix-shell -p nlohmann_json
|
|
||||||
```
|
|
||||||
|
|
||||||
On NixOS, the package can be installed system-wide by adding it to `configuration.nix`:
|
|
||||||
|
|
||||||
```nix
|
|
||||||
environment.systemPackages = [ pkgs.nlohmann_json ];
|
|
||||||
```
|
|
||||||
|
|
||||||
??? example "Example: CMake"
|
|
||||||
|
|
||||||
1. Create the following files:
|
|
||||||
|
|
||||||
```cpp title="example.cpp"
|
|
||||||
--8<-- "integration/nix/example.cpp"
|
|
||||||
```
|
|
||||||
|
|
||||||
```cmake title="CMakeLists.txt"
|
|
||||||
--8<-- "integration/nix/CMakeLists.txt"
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Enter a shell that provides the package, CMake, and a C++ compiler:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
nix-shell -p nlohmann_json cmake
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Compile the code:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
cmake -S . -B build
|
|
||||||
cmake --build build
|
|
||||||
```
|
|
||||||
|
|
||||||
## Other package managers
|
## Other package managers
|
||||||
|
|
||||||
The library is also contained in many other package repositories; [Repology](https://repology.org/project/nlohmann-json/versions) tracks the packaged
|
The library is also contained in many other package repositories; [Repology](https://repology.org/project/nlohmann-json/versions) tracks the packaged
|
||||||
|
|||||||
@@ -445,8 +445,7 @@ json_test_add_test_for(src/unit-stream-bulk-scan.cpp
|
|||||||
# with other values of JSON_UBJSON_VALUELESS_ELEMENTS_PER_BYTE: 1 (the smallest),
|
# with other values of JSON_UBJSON_VALUELESS_ELEMENTS_PER_BYTE: 1 (the smallest),
|
||||||
# 1000000 (so large that the budget cannot be reached), and the largest value of
|
# 1000000 (so large that the budget cannot be reached), and the largest value of
|
||||||
# a 64-bit integer (which saturates the limit already at the first byte, and is
|
# a 64-bit integer (which saturates the limit already at the first byte, and is
|
||||||
# clamped to the largest std::size_t where that has 32 bits). The file does not
|
# clamped to the largest std::size_t where that has 32 bits)
|
||||||
# mention JSON_HAS_CPP_<n>, so only C++11 is built unless the standards are forced
|
|
||||||
json_test_set_test_options(test-ubjson_valueless_rate_1
|
json_test_set_test_options(test-ubjson_valueless_rate_1
|
||||||
COMPILE_DEFINITIONS JSON_UBJSON_VALUELESS_ELEMENTS_PER_BYTE=1
|
COMPILE_DEFINITIONS JSON_UBJSON_VALUELESS_ELEMENTS_PER_BYTE=1
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
#include "doctest_compatibility.h"
|
#include "doctest_compatibility.h"
|
||||||
|
|
||||||
#define JSON_TESTS_PRIVATE
|
#define JSON_TESTS_PRIVATE
|
||||||
@@ -15,6 +22,7 @@ using nlohmann::json;
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <valarray>
|
#include <valarray>
|
||||||
|
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||||
#if JSON_HAS_RANGES
|
#if JSON_HAS_RANGES
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
#include "doctest_compatibility.h"
|
#include "doctest_compatibility.h"
|
||||||
|
|
||||||
// capture whether JSON_STRICT_NUL_HANDLING was enabled on the command line
|
// capture whether JSON_STRICT_NUL_HANDLING was enabled on the command line
|
||||||
@@ -517,6 +524,7 @@ TEST_CASE("parser class")
|
|||||||
CHECK(json::accept(u"[1]"));
|
CHECK(json::accept(u"[1]"));
|
||||||
CHECK(json::parse(U"[1]") == json({1}));
|
CHECK(json::parse(U"[1]") == json({1}));
|
||||||
CHECK(json::accept(U"[1]"));
|
CHECK(json::accept(U"[1]"));
|
||||||
|
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||||
#if defined(__cpp_char8_t)
|
#if defined(__cpp_char8_t)
|
||||||
CHECK(json::parse(u8"[1]") == json({1}));
|
CHECK(json::parse(u8"[1]") == json({1}));
|
||||||
CHECK(json::accept(u8"[1]"));
|
CHECK(json::accept(u8"[1]"));
|
||||||
@@ -2502,7 +2510,7 @@ TEST_CASE("text of float tokens")
|
|||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
std::copy_if(events.begin(), events.end(), std::back_inserter(result), [](const std::string & e)
|
std::copy_if(events.begin(), events.end(), std::back_inserter(result), [](const std::string & e)
|
||||||
{
|
{
|
||||||
return e.compare(0, 13, "number_float(") == 0;
|
return e.compare(0, 13, "number_float(") == 0; // NOLINT(modernize-use-starts-ends-with): C++11
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -3103,7 +3111,7 @@ TEST_CASE("object keys are delivered decoded and validated")
|
|||||||
std::vector<std::string> keys;
|
std::vector<std::string> keys;
|
||||||
for (const auto& e : l.events)
|
for (const auto& e : l.events)
|
||||||
{
|
{
|
||||||
if (e.compare(0, 4, "key(") == 0)
|
if (e.compare(0, 4, "key(") == 0) // NOLINT(modernize-use-starts-ends-with): C++11
|
||||||
{
|
{
|
||||||
keys.push_back(e.substr(4, e.size() - 5));
|
keys.push_back(e.substr(4, e.size() - 5));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
#include "doctest_compatibility.h"
|
#include "doctest_compatibility.h"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -17,6 +24,7 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||||
#if JSON_HAS_THREE_WAY_COMPARISON
|
#if JSON_HAS_THREE_WAY_COMPARISON
|
||||||
#include <compare>
|
#include <compare>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
#include "doctest_compatibility.h"
|
#include "doctest_compatibility.h"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -272,6 +279,7 @@ struct generator
|
|||||||
TEST_CASE("json_view string_ref")
|
TEST_CASE("json_view string_ref")
|
||||||
{
|
{
|
||||||
// std::string_view in C++17, a stand-in with the same members before
|
// std::string_view in C++17, a stand-in with the same members before
|
||||||
|
// JSON_HAS_CPP_17 (do not remove; see note at top of file)
|
||||||
using nlohmann::detail::view::string_ref;
|
using nlohmann::detail::view::string_ref;
|
||||||
const std::string text = "abc";
|
const std::string text = "abc";
|
||||||
const string_ref r(text);
|
const string_ref r(text);
|
||||||
@@ -945,7 +953,7 @@ TEST_CASE("json_view document_data::holds() (the debug check of read())")
|
|||||||
|
|
||||||
SECTION("current edit buffer")
|
SECTION("current edit buffer")
|
||||||
{
|
{
|
||||||
d->edits.reset(new document_data::edit_state()); // NOLINT(cppcoreguidelines-owning-memory)
|
d->edits.reset(new document_data::edit_state()); // NOLINT(cppcoreguidelines-owning-memory,modernize-make-unique)
|
||||||
CHECK(!d->holds(other.data(), other.size()));
|
CHECK(!d->holds(other.data(), other.size()));
|
||||||
d->edits->texts.emplace_back(new char[16]); // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-owning-memory)
|
d->edits->texts.emplace_back(new char[16]); // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays,cppcoreguidelines-owning-memory)
|
||||||
d->edits->text_cap = 16;
|
d->edits->text_cap = 16;
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
#include "doctest_compatibility.h"
|
#include "doctest_compatibility.h"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -348,6 +355,7 @@ static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<unsigned c
|
|||||||
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<wchar_t>::value, "wchar_t is refused");
|
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<wchar_t>::value, "wchar_t is refused");
|
||||||
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<char16_t>::value, "char16_t is refused");
|
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<char16_t>::value, "char16_t is refused");
|
||||||
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<char32_t>::value, "char32_t is refused");
|
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<char32_t>::value, "char32_t is refused");
|
||||||
|
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||||
#if defined(__cpp_char8_t)
|
#if defined(__cpp_char8_t)
|
||||||
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<char8_t>::value, "char8_t is refused");
|
static_assert(nlohmann::detail::recursion_depth_limit_is_char_or_bool<char8_t>::value, "char8_t is refused");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
#include "doctest_compatibility.h"
|
#include "doctest_compatibility.h"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@@ -23,8 +30,11 @@ using nlohmann::json;
|
|||||||
#include <valarray>
|
#include <valarray>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// JSON_HAS_CPP_17 (do not remove; see note at top of file)
|
||||||
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
|
#if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1)
|
||||||
#if __has_include(<filesystem>)
|
// libstdc++ 8 needs -lstdc++fs for std::filesystem (GCC bug 90050), which clang on such a
|
||||||
|
// libstdc++ does not get from the test options
|
||||||
|
#if __has_include(<filesystem>) && (!defined(_GLIBCXX_RELEASE) || _GLIBCXX_RELEASE >= 9)
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#define TO_JSON_RVALUE_HAS_FS 1
|
#define TO_JSON_RVALUE_HAS_FS 1
|
||||||
#endif
|
#endif
|
||||||
@@ -244,6 +254,7 @@ TEST_CASE("to_json from rvalue containers")
|
|||||||
SECTION("std::filesystem::path rvalue is still a string")
|
SECTION("std::filesystem::path rvalue is still a string")
|
||||||
{
|
{
|
||||||
CHECK(json(std::filesystem::path("a/b")) == json("a/b"));
|
CHECK(json(std::filesystem::path("a/b")) == json("a/b"));
|
||||||
|
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||||
#ifdef __cpp_lib_char8_t
|
#ifdef __cpp_lib_char8_t
|
||||||
CHECK(json(std::u8string(u8"a/b")) == json("a/b"));
|
CHECK(json(std::u8string(u8"a/b")) == json("a/b"));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2026 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
// cmake/test.cmake selects the C++ standard versions with which to build a
|
||||||
|
// unit test based on the presence of JSON_HAS_CPP_<VERSION> macros.
|
||||||
|
// When using macros that are only defined for particular versions of the standard
|
||||||
|
// (e.g., JSON_HAS_FILESYSTEM for C++17 and up), please mention the corresponding
|
||||||
|
// version macro in a comment close by, like this:
|
||||||
|
// JSON_HAS_CPP_<VERSION> (do not remove; see note at top of file)
|
||||||
|
|
||||||
// The budget for the elements of the UBJSON containers of a valueless type
|
// The budget for the elements of the UBJSON containers of a valueless type
|
||||||
// ('Z', 'T', 'F') of a whole input: 1048576 plus
|
// ('Z', 'T', 'F') of a whole input: 1048576 plus
|
||||||
// JSON_UBJSON_VALUELESS_ELEMENTS_PER_BYTE for every byte read (see
|
// JSON_UBJSON_VALUELESS_ELEMENTS_PER_BYTE for every byte read (see
|
||||||
@@ -92,6 +99,7 @@ static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<unsigned
|
|||||||
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<wchar_t>::value, "wchar_t is refused");
|
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<wchar_t>::value, "wchar_t is refused");
|
||||||
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<char16_t>::value, "char16_t is refused");
|
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<char16_t>::value, "char16_t is refused");
|
||||||
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<char32_t>::value, "char32_t is refused");
|
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<char32_t>::value, "char32_t is refused");
|
||||||
|
// JSON_HAS_CPP_20 (do not remove; see note at top of file)
|
||||||
#if defined(__cpp_char8_t)
|
#if defined(__cpp_char8_t)
|
||||||
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<char8_t>::value, "char8_t is refused");
|
static_assert(nlohmann::detail::valueless_elements_rate_is_char_or_bool<char8_t>::value, "char8_t is refused");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in new issue
Block a user