Compare commits

..
Author SHA1 Message Date
Niels Lohmann afea570755 json_view: fix GCC useless-cast, MSVC C4127, and MinGW object size
- drop the redundant int cast of the promoted uint16_t shift (-Wuseless-cast)
- route the constant part of the float-pair condition through enabled() (C4127)
- split unit-json_view_dump.cpp in three files for the MinGW assembler

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 10:45:57 +01:00
Niels Lohmann e7d245db7e json_view: dump canada.json faster than yyjson (batched float decisions)
Dump of float tokens of 16 or 17 digits without an exponent (SIMD targets,
little-endian), in batches of up to 256 floats ahead of the walk, one loop
per step:
- the digits (16 bytes at a time) and the token's last four digits;
- locate_token(): Eisel-Lemire's product gives the double x, and x's position
  relative to the token is exact in a 64-bit fixed-point number (56 bits after
  the point of the token's last digit), with the radius of its interval;
- token_digits_1/2(), one loop per kind (g): the multiple of 10^g nearest to x
  if it is in the interval, else the multiple of 10^(g - 1) nearest to x, the
  digits that dump() (Zmij) writes. Exact ties between two candidates (like
  754570942.33984373, whose double is ...33984375) are left to the full
  conversion;
- the output is the token with its last four digits replaced; a rounding that
  carries further goes to the writer of Zmij's results.
The batch storage is on the heap (allocated by the first conversion), and a
pair of floats like [x, y] in a read-only document is written without a
frame. Reading: get<double>() converts such tokens with a lean Eisel-Lemire
(coordinate_float()).

Output is byte-identical to the previous writer: 10^9 generated tokens in one
array and 3 * 10^8 in arrays of 1 to 9 elements on Apple M1, 2.5 * 10^8 and
10^8 on x86-64 (all exponents, subnormals, 15-18 digits, exact binary
fractions and ties, near-short decimals); get<double>() equals json::parse
on 5 * 10^7 values.

compare.py --download, Apple M1 Max, clang 21, 30 rounds, two runs (and two
with aligned code: -falign-loops=64 -mllvm -align-all-functions=6); json_view,
and the factor of yyjson 0.13.0 over it:
- canada dump      3636 -> 1623 us (0.47x -> 1.06x; aligned 1.05x)
- canada traverse  2287 -> 1817 us (0.85x -> 1.07x; aligned 0.99x)
- canada patch     4628 -> 2735 us (0.80x -> 1.36x)
- canada update    4763 -> 2911 us (0.78x -> 1.28x)
Linux x86-64 (Haswell VPS, GCC 13, one run): canada dump 0.53x -> 0.72x,
traverse 0.89x -> 0.95x, patch 1.01x -> 1.17x, update 0.96x -> 1.13x.

Open: canada traverse in the aligned build (0.99x) and canada dump on x86-64
(0.72x) are still behind yyjson. Canada parse and select are about 2 % slower
in bench_view in both builds, with identical parser code (likely layout; the
corpus parse row is not slower). In the plain build only, rpc, status, and
twitter dump are 2-4 % slower (0-6 % faster in the aligned build).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 07:23:43 +01:00
Niels Lohmann d38a04bd3e json_view: faster float tokens of 16 to 19 digits (canada dump, traverse)
Reading:
- layout_decimal() reads tokens of 16 to 19 digits 16 bytes at a time
  (NEON / SSE2) and layout_float() sends them to Eisel-Lemire directly,
  without the fast-path check that mixed data mispredicts.

Dump (AArch64 only):
- Fixed-notation tokens of 16 or 17 digits are converted in batches ahead
  of the walk, one loop per step: digits, Eisel-Lemire, and an exact 8.56
  fixed-point choice of the shortest digits (shortest_token_digits(), in
  place of Zmij for these tokens). The output is the token with its last
  eight digits replaced. On x86-64 (Haswell, GCC 13 / Clang 18) the batch
  was not faster, so it is not used there.
- Output is byte-identical to the previous writer: 10^9 generated tokens
  on M1 (all exponents, subnormals, 15-18 digits, exact binary fractions,
  near-short decimals) and 2.5 * 10^8 on x86-64, plus canada, twitter and
  citm_catalog in compact, indented, and ensure_ascii form.

compare.py --download, M1 Max, clang 21, 30 rounds, two runs and aligned
builds; json_view, and the factor of yyjson 0.13.0 over it:
- canada dump      3636 -> 2597 us (0.47x -> 0.66x)
- canada traverse  2300 -> 2059 us (0.85x -> 0.96x)
- canada patch     4650 -> 3550 us (0.80x -> 1.05x)
- canada update    4882 -> 3813 us (0.78x -> 1.00x)
Linux x86-64 (umbrella, GCC 13): canada traverse 0.89x -> 0.95x, patch
0.98x -> 1.02x, update 0.96x -> 1.01x, dump 0.53x -> 0.57x.

Open: the dump and traverse targets (>= 1.0x) are missed. The dump is
bounded by the shortest-digits step (~8 ns per float, one multiply chain
per float). Three rows are more than 1 % slower than before in both the
plain and the aligned build, without a known cause (the parser's machine
code is identical, and these documents do not use the new float path):
- edit status patch          +2.7 % (aligned +1.9 %)
- edit citm_catalog update   +1.7 % (aligned +1.5 %)
- view jeopardy select       +1.4 % (aligned +1.0 %)

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 07:23:42 +01:00
430 changed files with 3364 additions and 6052 deletions

No files matched your search

+7 -36
View File
@@ -1,33 +1,3 @@
# Style or vendor rule sets that do not fit a header-only library:
# altera-*, fuchsia-*, llvmlibc-*, android-cloexec-fopen, boost-use-ranges, llvm-header-guard,
# llvm-include-order, llvm-prefer-static-over-anonymous-namespace, llvm-use-ranges,
# misc-use-anonymous-namespace, google-runtime-float, google-runtime-int, hicpp-signed-bitwise,
# bugprone-signed-bitwise, hicpp-explicit-conversions, google-explicit-constructor,
# cppcoreguidelines-explicit-constructor, misc-explicit-constructor (implicit conversions are the
# API), readability-trailing-comma,
# hicpp-avoid-goto / cppcoreguidelines-avoid-goto, hicpp-no-array-decay,
# hicpp-uppercase-literal-suffix, readability-uppercase-literal-suffix, modernize-use-trailing-return-type.
# Constructs the library needs on purpose (the library supports C++11 and legacy compilers):
# cppcoreguidelines-macro-usage, cppcoreguidelines-avoid-do-while (macros),
# cppcoreguidelines-pro-bounds-*, cppcoreguidelines-pro-type-reinterpret-cast,
# cppcoreguidelines-pro-type-union-access (parsers, serializers, basic_json's value union),
# cppcoreguidelines-avoid-const-or-ref-data-members, cppcoreguidelines-rvalue-reference-param-not-moved,
# cppcoreguidelines-avoid-non-const-global-variables, misc-non-private-member-variables-in-classes,
# misc-no-recursion (value walks are recursive, bounded by detail::recursion_depth_limit()),
# modernize-type-traits, modernize-use-constraints, modernize-use-ranges, modernize-use-std-numbers,
# modernize-use-designated-initializers, modernize-use-nodiscard, modernize-concat-nested-namespaces,
# readability-redundant-typename, readability-redundant-parentheses,
# readability-redundant-access-specifiers, readability-simplify-boolean-expr,
# readability-use-concise-preprocessor-directives, modernize-use-string-view,
# modernize-use-integer-sign-comparison (needs std::cmp_less; the flagged
# static_cast<std::size_t>(end - pos) < n comparisons are deliberate)
# (all need a newer standard or compiler than C++11, or would change macro-generated or
# deliberately explicit code).
# Too noisy to be useful (numeric parsing/formatting code, doctest, tests):
# bugprone-easily-swappable-parameters, cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers,
# readability-identifier-length, readability-function-cognitive-complexity, performance-enum-size,
# concurrency-mt-unsafe, misc-confusable-identifiers, misc-include-cleaner (run on its own for
# the consumer headers in cmake/ci.cmake).
# portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted # portability-avoid-pragma-once: kept disabled on purpose. #pragma once is accepted
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from # by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
# single_include, so there is nothing left to fix here. # single_include, so there is nothing left to fix here.
@@ -40,14 +10,14 @@ Checks: '*,
-android-cloexec-fopen, -android-cloexec-fopen,
-boost-use-ranges, -boost-use-ranges,
-bugprone-easily-swappable-parameters, -bugprone-easily-swappable-parameters,
-bugprone-signed-bitwise, -cert-err58-cpp,
-clang-analyzer-webkit.NoUncountedMemberChecker,
-concurrency-mt-unsafe, -concurrency-mt-unsafe,
-cppcoreguidelines-avoid-const-or-ref-data-members, -cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-avoid-do-while, -cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-goto, -cppcoreguidelines-avoid-goto,
-cppcoreguidelines-avoid-magic-numbers, -cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables, -cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-explicit-constructor,
-cppcoreguidelines-macro-usage, -cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access, -cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-array-to-pointer-decay,
@@ -56,15 +26,19 @@ Checks: '*,
-cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-reinterpret-cast,
-cppcoreguidelines-pro-type-union-access, -cppcoreguidelines-pro-type-union-access,
-cppcoreguidelines-rvalue-reference-param-not-moved, -cppcoreguidelines-rvalue-reference-param-not-moved,
-cppcoreguidelines-virtual-class-destructor,
-fuchsia-default-arguments-calls, -fuchsia-default-arguments-calls,
-fuchsia-default-arguments-declarations, -fuchsia-default-arguments-declarations,
-fuchsia-overloaded-operator, -fuchsia-overloaded-operator,
-google-explicit-constructor, -google-explicit-constructor,
-google-readability-function-size,
-google-runtime-float, -google-runtime-float,
-google-runtime-int, -google-runtime-int,
-hicpp-avoid-goto, -hicpp-avoid-goto,
-hicpp-explicit-conversions, -hicpp-explicit-conversions,
-hicpp-function-size,
-hicpp-no-array-decay, -hicpp-no-array-decay,
-hicpp-no-assembler,
-hicpp-signed-bitwise, -hicpp-signed-bitwise,
-hicpp-uppercase-literal-suffix, -hicpp-uppercase-literal-suffix,
-llvm-header-guard, -llvm-header-guard,
@@ -74,7 +48,6 @@ Checks: '*,
-llvmlibc-*, -llvmlibc-*,
-misc-use-anonymous-namespace, -misc-use-anonymous-namespace,
-misc-confusable-identifiers, -misc-confusable-identifiers,
-misc-explicit-constructor,
-misc-include-cleaner, -misc-include-cleaner,
-misc-no-recursion, -misc-no-recursion,
-misc-non-private-member-variables-in-classes, -misc-non-private-member-variables-in-classes,
@@ -82,22 +55,20 @@ Checks: '*,
-modernize-type-traits, -modernize-type-traits,
-modernize-use-constraints, -modernize-use-constraints,
-modernize-use-designated-initializers, -modernize-use-designated-initializers,
-modernize-use-integer-sign-comparison,
-modernize-use-nodiscard, -modernize-use-nodiscard,
-modernize-use-ranges, -modernize-use-ranges,
-modernize-use-string-view,
-modernize-use-std-numbers, -modernize-use-std-numbers,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,
-performance-enum-size, -performance-enum-size,
-portability-avoid-pragma-once, -portability-avoid-pragma-once,
-readability-function-cognitive-complexity, -readability-function-cognitive-complexity,
-readability-function-size,
-readability-identifier-length, -readability-identifier-length,
-readability-magic-numbers, -readability-magic-numbers,
-readability-redundant-access-specifiers, -readability-redundant-access-specifiers,
-readability-redundant-parentheses, -readability-redundant-parentheses,
-readability-redundant-typename, -readability-redundant-typename,
-readability-simplify-boolean-expr, -readability-simplify-boolean-expr,
-readability-trailing-comma,
-readability-uppercase-literal-suffix, -readability-uppercase-literal-suffix,
-readability-use-concise-preprocessor-directives' -readability-use-concise-preprocessor-directives'
+1 -2
View File
@@ -43,8 +43,7 @@ jobs:
- name: flawfinder_scan - name: flawfinder_scan
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20 uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
with: with:
# single_include/ is omitted: it is generated from include/ and would report every finding twice arguments: '--sarif ./'
arguments: '--sarif ./cmake ./docs ./include ./src ./tests ./tools'
output: 'flawfinder_results.sarif' output: 'flawfinder_results.sarif'
- name: Upload analysis results to GitHub Security tab - name: Upload analysis results to GitHub Security tab
+4 -4
View File
@@ -151,7 +151,7 @@ The `json` class provides an API for manipulating a JSON value. To create a `jso
```cpp ```cpp
#include <fstream> #include <fstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
// ... // ...
@@ -164,7 +164,7 @@ If using modules (enabled with `NLOHMANN_JSON_BUILD_MODULES`), this example beco
import std; import std;
import nlohmann.json; import nlohmann.json;
using nlohmann::json; using json = nlohmann::json;
// ... // ...
@@ -842,7 +842,7 @@ assert(p == p2);
To make this work with one of your types, you only need to provide two functions: To make this work with one of your types, you only need to provide two functions:
```cpp ```cpp
using nlohmann::json; using json = nlohmann::json;
namespace ns { namespace ns {
void to_json(json& j, const person& p) { void to_json(json& j, const person& p) {
@@ -1257,7 +1257,7 @@ See the page [quality assurance](https://json.nlohmann.me/community/quality_assu
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
// for convenience // for convenience
using nlohmann::json; using json = nlohmann::json;
``` ```
to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang). to the files you want to process JSON and set the necessary switches to enable C++11 (e.g., `-std=c++11` for GCC and Clang).
+1 -1
View File
@@ -45,7 +45,7 @@ Constant.
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+2 -2
View File
@@ -38,7 +38,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
```cpp ```cpp
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -64,7 +64,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -79,7 +79,7 @@ The default value is `0` (disabled — existing behavior is preserved).
```cpp ```cpp
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -98,7 +98,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#define JSON_BRACE_INIT_COPY_SEMANTICS 1 #define JSON_BRACE_INIT_COPY_SEMANTICS 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -54,7 +54,7 @@ The default value is `0` (disabled, the deprecated functions can still be called
```cpp ```cpp
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -72,7 +72,7 @@ The default value is `0` (disabled, the deprecated functions can still be called
#define JSON_DELETE_DEPRECATED_FUNCTIONS 1 #define JSON_DELETE_DEPRECATED_FUNCTIONS 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -39,7 +39,7 @@ The default value is `0`.
#define JSON_DISABLE_ENUM_SERIALIZATION 1 #define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
enum class Choice enum class Choice
{ {
@@ -66,7 +66,7 @@ The default value is `0`.
#define JSON_DISABLE_ENUM_SERIALIZATION 1 #define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
enum class Choice enum class Choice
{ {
@@ -99,7 +99,7 @@ The default value is `0`.
#define JSON_DISABLE_ENUM_SERIALIZATION 1 #define JSON_DISABLE_ENUM_SERIALIZATION 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
enum class Choice enum class Choice
{ {
@@ -92,7 +92,7 @@ The default value is `0`: streams are scanned in bulk.
#include <sstream> #include <sstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -115,7 +115,7 @@ The default value is `0`: streams are scanned in bulk.
#include <sstream> #include <sstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -72,7 +72,7 @@ The default value is `0` (disabled — existing behavior is preserved).
```cpp ```cpp
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -89,7 +89,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1 #define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -73,7 +73,7 @@ The default value is `0`: the file is locked once and read with the unlocked std
#include <cstdio> #include <cstdio>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -92,7 +92,7 @@ The default value is `0`: the file is locked once and read with the unlocked std
#include <cstdio> #include <cstdio>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+1 -1
View File
@@ -61,7 +61,7 @@ By default, `#!cpp JSON_NO_SIMD` is not defined, and vector instructions are use
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -94,7 +94,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <sstream> #include <sstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -115,7 +115,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <sstream> #include <sstream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -64,7 +64,7 @@ The default value is `0` (disabled, the behavior of version 3.12.0 and earlier i
```cpp ```cpp
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -81,7 +81,7 @@ The default value is `0` (disabled, the behavior of version 3.12.0 and earlier i
#define JSON_STRICT_BINARY_UTF8 1 #define JSON_STRICT_BINARY_UTF8 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -92,7 +92,7 @@ The default value is `0` (disabled — existing behavior is preserved).
```cpp ```cpp
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -109,7 +109,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#define JSON_STRICT_NUL_HANDLING 1 #define JSON_STRICT_NUL_HANDLING 1
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -77,7 +77,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <map> #include <map>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED }; enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
@@ -105,7 +105,7 @@ The default value is `0` (disabled — existing behavior is preserved).
#include <map> #include <map>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED }; enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
@@ -188,13 +188,10 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
``` ```
- [x] The code is checked with the latest [Cppcheck](https://cppcheck.sourceforge.io) with all warnings enabled. - [x] The code is checked with the latest [Cppcheck](https://cppcheck.sourceforge.io) with all warnings enabled.
- [x] The code is checked with the latest [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 52 enabled - [x] The code is checked with the latest [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 89 enabled
checkers. rules.
- [x] The code is checked with [Infer](https://fbinfer.com). - [x] The code is checked with [Infer](https://fbinfer.com).
- [x] The code is checked with [Codacy](https://app.codacy.com/gh/nlohmann/json/dashboard). - [x] The code is checked with [Codacy](https://app.codacy.com/gh/nlohmann/json/dashboard).
- [x] The code is scanned with [CodeQL](https://codeql.github.com), [Semgrep](https://semgrep.dev), and
[Flawfinder](https://dwheeler.com/flawfinder/) on every push and pull request and on a schedule; the findings are
reported to GitHub's code scanning.
## Dynamic analysis ## Dynamic analysis
@@ -207,8 +204,6 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
- [x] The test suite is executed with [Valgrind](https://valgrind.org) (Memcheck) to detect memory leaks. - [x] The test suite is executed with [Valgrind](https://valgrind.org) (Memcheck) to detect memory leaks.
- [x] The test suite is executed with [Sanitizers](https://github.com/google/sanitizers) (address sanitizer, undefined - [x] The test suite is executed with [Sanitizers](https://github.com/google/sanitizers) (address sanitizer, undefined
behavior sanitizer, integer overflow detection, nullability violations). behavior sanitizer, integer overflow detection, nullability violations).
- [x] The fuzz targets are run with [CIFuzz](https://google.github.io/oss-fuzz/getting-started/continuous-integration/)
on every pull request to catch regressions before they are merged.
## Dependencies ## Dependencies
@@ -228,8 +223,6 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
No release is made while such an alert is open. No release is made while such an alert is open.
- [x] Third-party code included in the repository for testing, such as [doctest](https://github.com/doctest/doctest), - [x] Third-party code included in the repository for testing, such as [doctest](https://github.com/doctest/doctest),
is updated manually. is updated manually.
- [x] The repository is evaluated with the [OpenSSF Scorecard](https://securityscorecards.dev) on a schedule and on
every push to the default branch, and the results are reported to GitHub's code scanning.
## Style check ## Style check
@@ -265,21 +258,4 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
- [x] The library is tested against relevant CMake versions: - [x] The library is tested against relevant CMake versions:
- CMake 3.5 (the earliest supported) - CMake 3.5 (the earliest supported)
- CMake 3.31.6 (the latest 3.x release) - CMake 3.31.6 (the latest 3.x release)
- CMake 4.0.0 (the first 4.x release) - CMake 4.0.0 (a very recent release)
!!! success "Requirement: Other build systems"
The library can be used with build systems and package managers other than CMake.
- [x] The library can be consumed with [Meson](https://json.nlohmann.me/integration/package_managers/) and the Swift
Package Manager; the installation with Meson and the resolution of `Package.swift` are tested in the CI.
!!! success "Requirement: Reproducible and verifiable builds"
The library can be built and tested without network access or a Git checkout, and its licensing is machine-readable.
- [x] The test suite is executed from an exported source tree without the `.git` directory and with the test data
being available offline.
- [x] The test suite is executed without the tests that change installed files to check that builds are reproducible.
- [x] The repository is checked for compliance with the [REUSE specification](https://reuse.software) so that the
license and copyright of every file is machine-readable.
- [x] The documentation is built with warnings treated as errors, and its links are checked regularly.
+1 -1
View File
@@ -2,7 +2,7 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <vector> #include <vector>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+3 -3
View File
@@ -2,19 +2,19 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
// a valid JSON text // a valid JSON text
const auto* valid_text = R"( auto valid_text = R"(
{ {
"numbers": [1, 2, 3] "numbers": [1, 2, 3]
} }
)"; )";
// an invalid JSON text // an invalid JSON text
const auto* invalid_text = R"( auto invalid_text = R"(
{ {
"strings": ["extra", "comma", ] "strings": ["extra", "comma", ]
} }
@@ -2,7 +2,7 @@
#include <string> #include <string>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+2 -2
View File
@@ -2,9 +2,9 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << '\n'; std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl;
} }
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
using namespace nlohmann::literals; using namespace nlohmann::literals;
int main() int main()
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
using namespace nlohmann::literals; using namespace nlohmann::literals;
int main() int main()
@@ -3,7 +3,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using namespace std::string_view_literals; using namespace std::string_view_literals;
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -3,7 +3,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using namespace std::string_view_literals; using namespace std::string_view_literals;
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+1 -1
View File
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
using nlohmann::ordered_json; using ordered_json = nlohmann::ordered_json;
int main() int main()
{ {
@@ -8,7 +8,7 @@
#include <valarray> #include <valarray>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <utility> #include <utility>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,9 +1,9 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json; using json = nlohmann::json;
using nlohmann::json_editable_document; using json_editable_document = nlohmann::json_editable_document;
using nlohmann::json_editable_view; using json_editable_view = nlohmann::json_editable_view;
int main() int main()
{ {
@@ -1,9 +1,9 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json; using json = nlohmann::json;
using nlohmann::json_editable_document; using json_editable_document = nlohmann::json_editable_document;
using nlohmann::json_editable_view; using json_editable_view = nlohmann::json_editable_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -4,8 +4,8 @@
#include <vector> #include <vector>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json; using json = nlohmann::json;
using nlohmann::json_document; using json_document = nlohmann::json_document;
using image_check = json_document::image_check; using image_check = json_document::image_check;
int main() int main()
@@ -2,7 +2,7 @@
#include <string> #include <string>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <string> #include <string>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -3,7 +3,7 @@
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
json_document parse_from_temporary_buffer() json_document parse_from_temporary_buffer()
{ {
@@ -2,7 +2,7 @@
#include <vector> #include <vector>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json; using json = nlohmann::json;
using nlohmann::json_editable_document; using json_editable_document = nlohmann::json_editable_document;
int main() int main()
{ {
@@ -3,7 +3,7 @@
#include <vector> #include <vector>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -4,7 +4,7 @@
#include <vector> #include <vector>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,9 +1,9 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json; using json = nlohmann::json;
using nlohmann::json_editable_document; using json_editable_document = nlohmann::json_editable_document;
using nlohmann::json_editable_view; using json_editable_view = nlohmann::json_editable_view;
int main() int main()
{ {
@@ -3,7 +3,7 @@
#include <string> #include <string>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <string> #include <string>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using json_pointer = nlohmann::json::json_pointer; using json_pointer = nlohmann::json::json_pointer;
int main() int main()
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,8 +2,8 @@
#include <numeric> #include <numeric>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -2,8 +2,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using json_pointer = nlohmann::json::json_pointer; using json_pointer = nlohmann::json::json_pointer;
int main() int main()
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -3,8 +3,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
// address has no direct conversion in get<T>(), so get<address>() falls back // address has no direct conversion in get<T>(), so get<address>() falls back
// to materialize().get<address>() -- a real nlohmann::json value is built // to materialize().get<address>() -- a real nlohmann::json value is built
@@ -2,8 +2,8 @@
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
#include <string> #include <string>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -2,8 +2,8 @@
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
#include <string> #include <string>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using json_pointer = nlohmann::json::json_pointer; using json_pointer = nlohmann::json::json_pointer;
int main() int main()
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -2,8 +2,8 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,9 +1,9 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::ordered_json_document; using ordered_json_document = nlohmann::ordered_json_document;
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <string> #include <string>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
int main() int main()
{ {
@@ -2,8 +2,8 @@
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
#include <string> #include <string>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json_view.hpp> #include <nlohmann/json_view.hpp>
using nlohmann::json_document; using json_document = nlohmann::json_document;
using nlohmann::json_view; using json_view = nlohmann::json_view;
using json_pointer = nlohmann::json::json_pointer; using json_pointer = nlohmann::json::json_pointer;
int main() int main()
+1 -1
View File
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
+2 -2
View File
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -12,5 +12,5 @@ int main()
json j = json::binary(vec, 42); json j = json::binary(vec, 42);
// output type and subtype // output type and subtype
std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << '\n'; std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << std::endl;
} }
+2 -2
View File
@@ -2,9 +2,9 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << '\n'; std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << std::endl;
} }
+2 -2
View File
@@ -2,9 +2,9 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << '\n'; std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl;
} }
@@ -4,7 +4,7 @@
// define a byte container based on std::vector // define a byte container based on std::vector
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>; using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -19,5 +19,5 @@ int main()
// (3) create container with subtype // (3) create container with subtype
auto c3 = byte_container_with_subtype(bytes, 42); auto c3 = byte_container_with_subtype(bytes, 42);
std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << '\n'; std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << std::endl;
} }
@@ -4,7 +4,7 @@
// define a byte container based on std::vector // define a byte container based on std::vector
using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>; using byte_container_with_subtype = nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>;
using nlohmann::json; using json = nlohmann::json;
int main() int main()
{ {
@@ -15,5 +15,5 @@ int main()
auto c2 = byte_container_with_subtype(bytes, 42); auto c2 = byte_container_with_subtype(bytes, 42);
std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype() std::cout << std::boolalpha << "c1.has_subtype() = " << c1.has_subtype()
<< "\nc2.has_subtype() = " << c2.has_subtype() << '\n'; << "\nc2.has_subtype() = " << c2.has_subtype() << std::endl;
} }
@@ -19,5 +19,5 @@ int main()
<< "c1 == c2: " << (c1 == c2) << '\n' << "c1 == c2: " << (c1 == c2) << '\n'
<< "c1 == c3: " << (c1 == c3) << '\n' << "c1 == c3: " << (c1 == c3) << '\n'
<< "c3 == c4: " << (c3 == c4) << '\n' << "c3 == c4: " << (c3 == c4) << '\n'
<< "c3 == c5: " << (c3 == c5) << '\n'; << "c3 == c5: " << (c3 == c5) << std::endl;
} }
Loaded 100 of 430 files, more files were not shown because too many files have changed in this diff. Show more