Compare commits

..
Author SHA1 Message Date
Niels Lohmann d4faace387 Merge develop into perf/view-compare
Develop fixed the VS 2015 build of the DOM parser itself (#5916): its
json_sax.hpp is kept, so this branch no longer changes the file.
single_include is a fresh amalgamation.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:13:26 +01:00
Niels Lohmann 2a56afc714 Fix VS 2015 build of the DOM parser (#5882) (#5916)
- Name std::hash only once the object type has emplace_new_key: VS 2015
  static-asserts on std::hash of a type without one (alt_string) instead of
  reporting a substitution failure (C2338).
- Replace the std::copy calls on frames by loops: VS 2015 reports raw
  pointers handed to std::copy as C4996, an error under /WX.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:08:58 +01:00
Niels Lohmann d176d8d61e Exclude single_include from flawfinder scan (#5912)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:08:36 +01:00
Niels Lohmann 1cf5492bcd docs: byte layout sections, glossary entries, and QA page update (#5910)
* docs: byte layout sections, glossary, and QA page updates

- Move "Byte layout" of each binary format to its own section before
  "Serialization" and describe the idea of the format.
- Glossary: add LLDB and other terms used throughout the documentation.
- quality_assurance: correct Clang Static Analyzer and CMake entries; add
  CodeQL, Semgrep, Flawfinder, CIFuzz, OpenSSF Scorecard, REUSE, Meson/SwiftPM,
  and reproducibility checks.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* docs: drop unused length colour from CBOR and MessagePack byte layout legends

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:08:14 +01:00
Niels Lohmann 330fbead59 Document clang-tidy exclusions, drop unneeded ones, and clean up doc examples (#5909)
* Document clang-tidy exclusions and drop unneeded ones

Re-enable every excluded check in a run of clang-tidy 22 over all tests
and remove the seven that never fire (cert-err58-cpp,
clang-analyzer-webkit.NoUncountedMemberChecker,
cppcoreguidelines-virtual-class-destructor, google-readability-function-size,
hicpp-function-size, hicpp-no-assembler, readability-function-size).

Document the reason for every remaining exclusion at the top of the file.

Exclude in advance the checks that only exist in clang-tidy 23 and are
noise here (bugprone-signed-bitwise, *-explicit-constructor,
readability-trailing-comma, modernize-use-string-view), plus
modernize-use-integer-sign-comparison, which needs C++20 std::cmp_less
and flags deliberate casts.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Fix clang-tidy findings in documentation examples and replace redundant aliases

Apply clang-tidy fixes to the documentation examples:
- performance-avoid-endl: std::endl -> '\n'
- readability-qualified-auto: auto -> auto* / const auto*
- performance-for-range-copy: copy -> const reference
- google-readability-casting: C-style cast -> static_cast

Replace redundant aliases (readability-redundant-qualified-alias) such as
"using json = nlohmann::json;" with "using nlohmann::json;" in the
documentation, README, examples, tests, and benchmarks. Aliases at class
scope and aliases of other types (with_base_class_t etc.) are kept.

No changes to the library or its public API. All changed examples were
compiled and run; their output matches the stored .output files (except
max_size and meta, which depend on the platform and compiler).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* Format doc examples with the pinned astyle

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:07:51 +01:00
Niels Lohmann fe231dc692 docs: write std::chrono durations as unit/value objects; reword a title with escaped quotes (#5911)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:07:32 +01:00
Niels Lohmann ffd4242dc2 Docs: fill documentation gaps found in user questions (#5907)
* Docs: fill documentation gaps found in user questions

Add pages on class-hierarchy/smart-pointer/variant/chrono recipes, working
without exceptions, and large, streamed and partial input. Extend the FAQ
(23 entries, Known bugs first), parse error documentation (empty-input
checklist, line/column, diagnostic positions), element access, conversions,
creating values, ADL troubleshooting, memory, and build/distribution notes.
Add 14 examples with generated output. Correct the statement that parse errors
cannot be recovered from with -fno-exceptions.

The topics come from recurring questions on Stack Overflow, Reddit, Hacker
News, YouTube, and the project's GitHub discussions and issues.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

* docs: declare range-for lists in variables to keep astyle quiet

astyle reformats a braced init list placed directly in a range-for
header; declare the list first so check_amalgamation passes.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:07:13 +01:00
Niels Lohmann 165f91ed3c Build the DOM parser with Visual Studio 2015 again
Since #5882, the three VS 2015 jobs of AppVeyor fail on develop:
- the detection of keys that can be indexed instantiated std::hash for
  every string type, which VS 2015 rejects with a static_assert for a type
  it does not hash (alt_string): std::hash is now looked at only for
  objects in a vector
- the frame stack copied its frames with std::copy to a raw pointer, which
  VS 2015 reports as unsafe (C4996, an error with /WX): a loop now

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:04:43 +01:00
Niels Lohmann 7833865dbd Merge develop into perf/view-compare
single_include is a fresh amalgamation.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-25 12:00:01 +01:00
Niels Lohmann 9707519b24 Move the json_view comparison tests into their own file
With the tests this branch adds, the object file of unit-json_view_dump.cpp
got too large for the MinGW x64 assembler ("file too big"). The test case
"json_view comparison" is now unit-json_view_compare.cpp, unchanged and
also built with C++17.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-24 20:03:58 +02:00
Niels Lohmann 2d040c89d0 Merge develop into perf/view-compare
Develop silenced the same Infer false positive in materialize() (#5905):
its version is kept. single_include is a fresh amalgamation.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-24 17:14:02 +02:00
Niels Lohmann 182b31f902 Mark Infer's null dereference in materialize() as a false positive
Infer (ci_infer, also red on develop since #5882) reports a null
dereference in json_sax_dom_parser::null() called from materialize(). The
member pointer the parser stores a value of an object in is set by the
key() before it, so it is not null there.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-24 15:40:31 +02:00
Niels Lohmann 6775994761 Merge develop into perf/view-compare
Resolves the conflict in unit-json_view_image.cpp, where develop (#5889)
and this branch each added a section to "json_view images: errors": both
are kept. single_include is a fresh amalgamation.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-24 07:48:54 +02:00
Niels Lohmann 70d1baa57a Remove a nested duplicate guard from the json_view image test
clang-tidy reported the inner #if !defined(JSON_NOEXCEPTION) as
redundant (the test case is in the same #if) and a find() != npos, which
gets the NOLINT the other tests use.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-23 18:53:34 +02:00
Niels Lohmann 536672e927 Dispatch on the compile-time conditions of the json_view comparison
MSVC (/W4 /WX) reported C4127 (conditional expression is constant) for
the template parameter EA and the object type's ordering in an if
condition; both are now tag-dispatched.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-23 09:44:39 +02:00
Niels Lohmann 55cdc93ff8 Keep the byte comparison helpers in compare.hpp
Address review comments: bytes_equal() and bytes_less() move from node.hpp
to compare.hpp, their only user; key_less() no longer splits the comment of
resolve_indices() from its function; and the loop counters of bytes_equal()
and all_digits() are scoped to their loops.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-23 06:47:22 +02:00
Niels Lohmann db5bd7fbcc Fix the compiler and lint failures of the json_view comparison
- all_digits(): the lambda declares its constant itself; MSVC does not
  let a lambda without captures read a constexpr local of the function
- equal(): the frame's "in document order" index is a namespace-scope
  constant (document_order); the local constexpr npos in the default
  member initializers of the local struct crashed GCC 9 and MinGW GCC
  and was not found by MSVC
- keys_differ_early() keeps the first keys in std::arrays (cpplint:
  variable-length arrays; clang-tidy: C arrays), and the basic_json
  side's first_keys() is not noexcept (key() may throw)
- the numbers of one type are compared in an if chain instead of a
  nested conditional operator
- the dump test avoids C arrays and temporary string concatenations

View comparison instructions are unchanged (Apple clang, twitter, citm,
canada: -0.1 % to +0.1 %).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-22 20:13:22 +02:00
Niels Lohmann 89bd5d63e1 Rename names that Flawfinder takes for the file function open()
The comparison cursors' open() is now enter(), and a test's open and
close strings are head and tail.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-22 13:27:54 +02:00
Niels Lohmann 3fb7d9c710 Check the float tokens of a json_document image without a sort and a scan of every character
load(image_check::full) checked every float token of an image by sorting
the token ranges, scanning the token character by character, and comparing
the digit layout with the node's. Now:

- the ranges are sorted only if they are not sorted already (save() writes
  them in the order of the nodes, so they are);
- a token of the shape [-]digits.digits whose digit counts are the ones the
  node records (nearly all of them) is accepted by checking its digits eight
  at a time, without the general scan;
- the general scan skips runs of digits eight at a time.

Damaged tokens are still rejected as before: the check accepts exactly the
tokens that the general scan accepts.

Instructions of load(image_check::full) (develop -> now):

  macOS arm64        canada 44.6M -> 30.9M (-31 %), jeopardy 11.3M -> 10.7M,
                     citm 10.4M -> 10.0M, twitter 5.06M -> 4.94M
  Linux GCC 13       canada -50 %, jeopardy -43 %, twitter -31 %, citm -28 %
  Linux Clang 18     canada -42 %, jeopardy -48 %, twitter -35 %, citm -32 %

image_check::bounds is unchanged (within 0.4 %).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-22 09:30:44 +02:00
Niels Lohmann fa8134ae85 Compare json_view values without a vector per container and a basic_json per number
operator== of views (view/view, view/json, and editable documents) built two
vectors of members for every object it entered, sorted them with stable_sort
for every object, and converted each number to a basic_json value. It now:

- keeps the members of all open objects in one vector (reserved with
  geometric growth, so that nested objects do not reallocate), and orders
  them by insertion sort for up to 16 members, or not at all when the keys
  ascend already;
- compares numbers of one type directly, and builds a basic_json only for
  numbers of different types;
- compares short texts (keys, numbers, most strings) with two overlapping
  loads (bytes_equal(), in node.hpp);
- first walks both documents in lockstep, in the order of their text, which
  finds most pairs of equal values without the work of the comparison. The
  walk only enters an object if the comparison would visit its members in the
  same order (the object type keeps the order, the keys ascend, or all values
  are scalars), so a difference is never found later than before, and it
  records the containers it found different, so that the comparison does not
  walk them again;
- rejects values of different types and arrays of different sizes before any
  of this, and, for an object type that keeps the order, objects whose first
  (up to four) members have different keys, which ends a comparison that
  differs near the start without preparing the members.

Results are unchanged: numbers compare by value across types, duplicate keys
resolve as parse() resolves them, and objects compare in document order for
ordered_json and by key otherwise.

Instructions of one comparison of a document with an equal copy, macOS arm64
(develop -> now), json_document / ordered_json_document / editable:

  twitter    16.1M -> 7.0M   17.7M -> 1.5M    16.6M -> 7.3M
  citm       45.0M -> 3.4M   47.0M -> 3.2M    45.7M -> 4.3M
  canada    111.4M -> 13.7M  111.4M -> 13.7M  113.3M -> 15.0M
  jeopardy   26.2M -> 3.7M   27.3M -> 3.7M    26.6M -> 12.1M

and of a view with a basic_json value:

  twitter    11.4M -> 5.9M   11.2M -> 7.3M    11.6M -> 5.9M
  citm       33.9M -> 9.7M   32.6M -> 9.1M    34.6M -> 9.8M
  canada     92.9M -> 32.1M  92.9M -> 32.1M   93.9M -> 32.8M

and Linux instruction counts (GCC 13 / Clang 18) of the same comparisons:

  document with an equal copy   json_document     ordered_json_document   editable
    twitter                     -49 % / -52 %     -89 % / -89 %           -48 % / -50 %
    citm                        -90 % / -89 %     -91 % / -90 %           -88 % / -87 %
    jeopardy (4,000 questions)  -85 % / -85 %     -86 % / -86 %           -46 % / -49 %
  view with a basic_json value
    twitter                     -41 % / -45 %     -28 % / -35 %           -45 % / -44 %
    citm                        -63 % / -65 %     -63 % / -66 %           -65 % / -64 %
    jeopardy                    -39 % / -43 %     -14 % / -24 %           -44 % / -43 %

A sweep that places one difference at about 2,100 positions of eight
documents (a token at an even spacing, the first and last tokens, the first,
middle and last member of the root removed, one appended, the document
wrapped) in five kinds of comparison (view/view of read-only and of editable
documents, view/json, json_document, editable/view) finds the same results as
before and no placement slower on the Mac (Clang); on Linux no placement is
slower than 3 % (Clang and GCC).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-22 09:30:42 +02:00
430 changed files with 6052 additions and 3364 deletions

No files matched your search

+36 -7
View File
@@ -1,3 +1,33 @@
# 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.
@@ -10,14 +40,14 @@ Checks: '*,
-android-cloexec-fopen, -android-cloexec-fopen,
-boost-use-ranges, -boost-use-ranges,
-bugprone-easily-swappable-parameters, -bugprone-easily-swappable-parameters,
-cert-err58-cpp, -bugprone-signed-bitwise,
-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,
@@ -26,19 +56,15 @@ 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,
@@ -48,6 +74,7 @@ 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,
@@ -55,20 +82,22 @@ 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'
+2 -1
View File
@@ -43,7 +43,8 @@ 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:
arguments: '--sarif ./' # single_include/ is omitted: it is generated from include/ and would report every finding twice
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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using nlohmann::json;
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED }; enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
@@ -188,10 +188,13 @@ 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 89 enabled - [x] The code is checked with the latest [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 52 enabled
rules. checkers.
- [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
@@ -204,6 +207,8 @@ 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
@@ -223,6 +228,8 @@ 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
@@ -258,4 +265,21 @@ 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 (a very recent release) - CMake 4.0.0 (the first 4.x 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 json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -2,7 +2,7 @@
#include <vector> #include <vector>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using 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 json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
// a valid JSON text // a valid JSON text
auto valid_text = R"( const auto* valid_text = R"(
{ {
"numbers": [1, 2, 3] "numbers": [1, 2, 3]
} }
)"; )";
// an invalid JSON text // an invalid JSON text
auto invalid_text = R"( const 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << std::endl; std::cout << std::boolalpha << std::is_same<std::vector<json>, json::array_t>::value << '\n';
} }
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using 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 json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using 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 json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,8 +1,8 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
using ordered_json = nlohmann::ordered_json; using nlohmann::ordered_json;
int main() int main()
{ {
@@ -8,7 +8,7 @@
#include <valarray> #include <valarray>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
@@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json = nlohmann::json; using nlohmann::json;
using json_editable_document = nlohmann::json_editable_document; using nlohmann::json_editable_document;
using json_editable_view = nlohmann::json_editable_view; using 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 json = nlohmann::json; using nlohmann::json;
using json_editable_document = nlohmann::json_editable_document; using nlohmann::json_editable_document;
using json_editable_view = nlohmann::json_editable_view; using 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 json_document = nlohmann::json_document; using 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 json = nlohmann::json; using nlohmann::json;
using json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json = nlohmann::json; using nlohmann::json;
using json_editable_document = nlohmann::json_editable_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json = nlohmann::json; using nlohmann::json;
using json_editable_document = nlohmann::json_editable_document; using nlohmann::json_editable_document;
using json_editable_view = nlohmann::json_editable_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
int main() int main()
{ {
@@ -3,8 +3,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
using json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json = nlohmann::json; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using ordered_json_document = nlohmann::ordered_json_document; using nlohmann::ordered_json_document;
using json = nlohmann::json; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json_document = nlohmann::json_document; using nlohmann::json_document;
using json_view = nlohmann::json_view; using 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 json = nlohmann::json; using 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 json = nlohmann::json; using 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() << std::endl; std::cout << "type: " << j.type_name() << ", subtype: " << j.get_binary().subtype() << '\n';
} }
+2 -2
View File
@@ -2,9 +2,9 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using 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 << std::endl; std::cout << std::boolalpha << std::is_same<nlohmann::byte_container_with_subtype<std::vector<std::uint8_t>>, json::binary_t>::value << '\n';
} }
+2 -2
View File
@@ -2,9 +2,9 @@
#include <iomanip> #include <iomanip>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
using json = nlohmann::json; using nlohmann::json;
int main() int main()
{ {
std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << std::endl; std::cout << std::boolalpha << std::is_same<bool, json::boolean_t>::value << '\n';
} }
@@ -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 json = nlohmann::json; using 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) << std::endl; std::cout << json(c1) << "\n" << json(c2) << "\n" << json(c3) << '\n';
} }
@@ -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 json = nlohmann::json; using 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() << std::endl; << "\nc2.has_subtype() = " << c2.has_subtype() << '\n';
} }
@@ -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) << std::endl; << "c3 == c5: " << (c3 == c5) << '\n';
} }
Loaded 100 of 430 files, more files were not shown because too many files have changed in this diff. Show more