Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02d05057a5 | ||
|
|
444dba381f | ||
|
|
44f1bec789 | ||
|
|
2a56afc714 | ||
|
|
d176d8d61e | ||
|
|
1cf5492bcd | ||
|
|
330fbead59 | ||
|
|
fe231dc692 | ||
|
|
ffd4242dc2 | ||
|
|
cc917d7123 | ||
|
|
3eae5680d6 | ||
|
|
fe5e401870 | ||
|
|
52b72b5684 | ||
|
|
01139dc192 | ||
|
|
9c50bdd140 | ||
|
|
dd7686a269 | ||
|
|
e9c4fe3cdf | ||
|
|
1e9222f955 | ||
|
|
ffcd392be0 |
No files matched your search
+36
-7
@@ -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
|
||||
# by every supported compiler, and tools/amalgamate/amalgamate.py strips it from
|
||||
# single_include, so there is nothing left to fix here.
|
||||
@@ -10,14 +40,14 @@ Checks: '*,
|
||||
-android-cloexec-fopen,
|
||||
-boost-use-ranges,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-cert-err58-cpp,
|
||||
-clang-analyzer-webkit.NoUncountedMemberChecker,
|
||||
-bugprone-signed-bitwise,
|
||||
-concurrency-mt-unsafe,
|
||||
-cppcoreguidelines-avoid-const-or-ref-data-members,
|
||||
-cppcoreguidelines-avoid-do-while,
|
||||
-cppcoreguidelines-avoid-goto,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-explicit-constructor,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
|
||||
@@ -26,19 +56,15 @@ Checks: '*,
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,
|
||||
-cppcoreguidelines-pro-type-union-access,
|
||||
-cppcoreguidelines-rvalue-reference-param-not-moved,
|
||||
-cppcoreguidelines-virtual-class-destructor,
|
||||
-fuchsia-default-arguments-calls,
|
||||
-fuchsia-default-arguments-declarations,
|
||||
-fuchsia-overloaded-operator,
|
||||
-google-explicit-constructor,
|
||||
-google-readability-function-size,
|
||||
-google-runtime-float,
|
||||
-google-runtime-int,
|
||||
-hicpp-avoid-goto,
|
||||
-hicpp-explicit-conversions,
|
||||
-hicpp-function-size,
|
||||
-hicpp-no-array-decay,
|
||||
-hicpp-no-assembler,
|
||||
-hicpp-signed-bitwise,
|
||||
-hicpp-uppercase-literal-suffix,
|
||||
-llvm-header-guard,
|
||||
@@ -48,6 +74,7 @@ Checks: '*,
|
||||
-llvmlibc-*,
|
||||
-misc-use-anonymous-namespace,
|
||||
-misc-confusable-identifiers,
|
||||
-misc-explicit-constructor,
|
||||
-misc-include-cleaner,
|
||||
-misc-no-recursion,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
@@ -55,20 +82,22 @@ Checks: '*,
|
||||
-modernize-type-traits,
|
||||
-modernize-use-constraints,
|
||||
-modernize-use-designated-initializers,
|
||||
-modernize-use-integer-sign-comparison,
|
||||
-modernize-use-nodiscard,
|
||||
-modernize-use-ranges,
|
||||
-modernize-use-string-view,
|
||||
-modernize-use-std-numbers,
|
||||
-modernize-use-trailing-return-type,
|
||||
-performance-enum-size,
|
||||
-portability-avoid-pragma-once,
|
||||
-readability-function-cognitive-complexity,
|
||||
-readability-function-size,
|
||||
-readability-identifier-length,
|
||||
-readability-magic-numbers,
|
||||
-readability-redundant-access-specifiers,
|
||||
-readability-redundant-parentheses,
|
||||
-readability-redundant-typename,
|
||||
-readability-simplify-boolean-expr,
|
||||
-readability-trailing-comma,
|
||||
-readability-uppercase-literal-suffix,
|
||||
-readability-use-concise-preprocessor-directives'
|
||||
|
||||
|
||||
@@ -29,13 +29,6 @@ updates:
|
||||
- dependency-name: mermaid
|
||||
update-types: ["version-update:semver-major"]
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /.github/requirements
|
||||
schedule:
|
||||
interval: daily
|
||||
cooldown:
|
||||
default-days: 7
|
||||
|
||||
- package-ecosystem: pip
|
||||
directory: /tools/astyle
|
||||
schedule:
|
||||
@@ -43,7 +36,7 @@ updates:
|
||||
cooldown:
|
||||
default-days: 7
|
||||
ignore:
|
||||
# astyle is deliberately pinned (see tools/astyle/requirements.in): newer versions
|
||||
# astyle is deliberately pinned (see tools/astyle/requirements.txt): newer versions
|
||||
# reformat the code, and the pinned version defines the formatting CI enforces
|
||||
- dependency-name: astyle
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
meson==1.12.1
|
||||
@@ -1,10 +0,0 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile with Python 3.14
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --generate-hashes --no-emit-index-url --output-file=.github/requirements/meson.txt --strip-extras .github/requirements/meson.in
|
||||
#
|
||||
meson==1.12.1 \
|
||||
--hash=sha256:930bc7542cbd9f57009e182fd014eba48cf1a0180a7b9006d2d32d8f168d8b02 \
|
||||
--hash=sha256:ab0a6ca09f8ef70c564c8241fb5a23957886a0b53fb58412b5e07eaf07dba743
|
||||
# via -r .github/requirements/meson.in
|
||||
@@ -1 +0,0 @@
|
||||
semgrep==1.182.1
|
||||
File diff suppressed because it is too large.
Load diff
@@ -67,10 +67,10 @@ jobs:
|
||||
- name: Install astyle
|
||||
run: |
|
||||
python3 -mvenv venv
|
||||
venv/bin/pip3 install --require-hashes -r $MAIN_DIR/tools/astyle/requirements.txt
|
||||
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt
|
||||
|
||||
- name: Install generate_natvis dependencies
|
||||
run: pip3 install --require-hashes -r $MAIN_DIR/tools/generate_natvis/requirements.txt
|
||||
run: pip3 install -r $NATVIS_TOOL_DIR/requirements.txt
|
||||
|
||||
- name: Regenerate the tools/macro_builder tables in macro_scope.hpp
|
||||
run: |
|
||||
|
||||
@@ -31,12 +31,3 @@ jobs:
|
||||
persist-credentials: false
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
|
||||
with:
|
||||
# Semgrep pins mcp==1.29.0 and opentelemetry-api~=1.37.0 exactly
|
||||
# (.github/requirements/semgrep.txt), so these cannot be upgraded
|
||||
# until Semgrep lifts its pins. They do not apply to our use: CI
|
||||
# only runs `semgrep scan` on the checkout and never starts the MCP
|
||||
# server (GHSA-84m7-p3x7-pcfv, StreamableHTTP sessions) or parses
|
||||
# incoming trace context (GHSA-xcq7-p3pf-p88h, tracestate parsing).
|
||||
# Remove the entries once a Semgrep release allows the fixed versions.
|
||||
allow-ghsas: GHSA-84m7-p3x7-pcfv, GHSA-xcq7-p3pf-p88h
|
||||
@@ -43,7 +43,8 @@ jobs:
|
||||
- name: flawfinder_scan
|
||||
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
|
||||
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'
|
||||
|
||||
- name: Upload analysis results to GitHub Security tab
|
||||
|
||||
@@ -53,7 +53,7 @@ jobs:
|
||||
# SEMGREP_APP_TOKEN is still passed through so registry auth works if a
|
||||
# token is ever added.
|
||||
- name: Install Semgrep
|
||||
run: python3 -m pip install --user --require-hashes -r .github/requirements/semgrep.txt
|
||||
run: python3 -m pip install --user semgrep==1.168.0
|
||||
|
||||
# `semgrep scan --sarif` always exits 0 even with findings; continue-on-error
|
||||
# is a safety net so the SARIF upload still runs if the scan itself errors.
|
||||
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Check that Meson and pkg-config offer the CMake options
|
||||
run: make check_build_options
|
||||
- name: Install Meson
|
||||
run: pip install --require-hashes -r .github/requirements/meson.txt
|
||||
run: pip install meson
|
||||
- name: Install with Meson
|
||||
run: |
|
||||
meson setup build-meson --prefix=${{ github.workspace }}/install
|
||||
|
||||
@@ -151,7 +151,7 @@ The `json` class provides an API for manipulating a JSON value. To create a `jso
|
||||
```cpp
|
||||
#include <fstream>
|
||||
#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 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:
|
||||
|
||||
```cpp
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
namespace ns {
|
||||
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>
|
||||
|
||||
// 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).
|
||||
|
||||
@@ -341,13 +341,14 @@ def download(url, docs) -> str:
|
||||
raise ValueError(f'not an http(s) URL: {url}')
|
||||
req = urllib.request.Request(u.geturl(), headers={'User-Agent': USER_AGENT})
|
||||
# (the scheme is checked above)
|
||||
# nosemgrep: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected
|
||||
with urllib.request.urlopen(req, timeout=20) as r: # nosec B310
|
||||
data = r.read()
|
||||
ctype = r.headers.get_content_type()
|
||||
path = urllib.parse.unquote(u.path).lstrip('/')
|
||||
ext = os.path.splitext(path)[1]
|
||||
if u.query or not ext or path.endswith('/'):
|
||||
digest = hashlib.sha1(url.encode(), usedforsecurity=False).hexdigest()[:12]
|
||||
digest = hashlib.sha256(url.encode()).hexdigest()[:12]
|
||||
path = os.path.join(os.path.dirname(path), digest + CONTENT_TYPE_EXT.get(ctype, ext or '.bin'))
|
||||
rel = os.path.normpath(os.path.join('assets', 'external', u.hostname, path))
|
||||
out = os.path.join(docs, rel)
|
||||
|
||||
@@ -30,6 +30,14 @@ struct adl_serializer {
|
||||
- [**from_json**](from_json.md) - convert a JSON value to any value type
|
||||
- [**to_json**](to_json.md) - convert any value type to a JSON value
|
||||
|
||||
## See also
|
||||
|
||||
- [Arbitrary type conversions](../../features/arbitrary_types.md) - how to make your types convertible
|
||||
- [**get**](../basic_json/get.md) / [**get_to**](../basic_json/get_to.md) - convert a JSON value to a C++ type
|
||||
- [**basic_json**](../basic_json/basic_json.md) - construct a JSON value from a C++ value
|
||||
- [**NLOHMANN_DEFINE_TYPE_INTRUSIVE**](../macros/nlohmann_define_type_intrusive.md) - generate the conversion functions for a type
|
||||
- [Specializing enum conversion](../../features/enum_conversion.md)
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 2.1.0.
|
||||
@@ -23,6 +23,9 @@ Checks whether the input is valid JSON.
|
||||
respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to
|
||||
the iterator type with `operator!=`.
|
||||
|
||||
Ill-formed UTF-16 and UTF-32 sequences are rejected: a lone surrogate, a high surrogate that is not followed by its
|
||||
low surrogate, and a code point above `U+10FFFF` all make this function return `false`.
|
||||
|
||||
Unlike the [`parse()`](parse.md) function, this function neither throws an exception in case of invalid JSON input
|
||||
(i.e., a parse error) nor creates diagnostic information.
|
||||
|
||||
@@ -35,9 +38,12 @@ Unlike the [`parse()`](parse.md) function, this function neither throws an excep
|
||||
- a `#!c FILE` pointer (throws if null)
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters (throws if null)
|
||||
- a `std::string`
|
||||
- a `std::string` or a `std::string_view` (C++17)
|
||||
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
|
||||
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
|
||||
- wide characters (`wchar_t`, `char16_t`, `char32_t`), which are converted to UTF-8: a wide string object
|
||||
(`std::wstring`, `std::u16string`, `std::u32string`) or an array (e.g. a wide string literal); a pointer to a
|
||||
null-terminated wide string (e.g. `std::u16string::c_str()`) is not supported
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type, for instance.
|
||||
@@ -125,6 +131,21 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
|
||||
--8<-- "examples/accept__iterator_pair.output"
|
||||
```
|
||||
|
||||
??? example "Example: (3) reading from UTF-16 strings"
|
||||
|
||||
The encoding is deduced from the character type of the input. String literals like `u"..."`, `U"..."`, and
|
||||
`L"..."` work as well.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/accept__wide_string.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/accept__wide_string.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [parse](parse.md) - deserialize from a compatible input
|
||||
@@ -151,6 +172,9 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
|
||||
([`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md)).
|
||||
- Parsing from a `FILE*` locks the file once instead of once per character in version 3.13.0
|
||||
([`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md)).
|
||||
- Ill-formed UTF-16 and UTF-32 input (a lone surrogate, a high surrogate that is not followed by its low surrogate, or
|
||||
a code point above `U+10FFFF`) is rejected in version 3.13.0; before that, some such sequences were accepted or
|
||||
ended the input silently.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -239,9 +239,8 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
|
||||
1. Added in version 1.0.0.
|
||||
2. Added in version 1.0.0.
|
||||
3. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
||||
already supported by [`operator[]`](operator[].md), [`value`](value.md), [`find`](find.md), and other lookup
|
||||
functions.
|
||||
3. Added in version 3.11.0. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
||||
across the lookup functions.
|
||||
4. Added in version 2.0.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) instead of
|
||||
[`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) for a one-character array index that is not
|
||||
a digit (e.g., `/x`) in version 3.13.0, as it already did for longer ones.
|
||||
@@ -63,4 +63,4 @@ Constant.
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Adjusted code to return reference to binary values in version 3.8.0.
|
||||
- Binary values are supported since version 3.8.0.
|
||||
@@ -113,19 +113,22 @@ basic_json(basic_json&& other) noexcept;
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A(["initializer_list init"]) --> B{"empty, or every element is a 2-element<br/>array whose first element is a string?"}
|
||||
B -->|"yes"| C{"type_deduction"}
|
||||
B -->|"no"| D{"type_deduction"}
|
||||
A(["initializer_list init"]) --> B{{"empty, or every element is a 2-element<br/>array whose first element is a string?"}}
|
||||
B -->|"yes"| C{{"type_deduction"}}
|
||||
B -->|"no"| D{{"type_deduction"}}
|
||||
C -->|"true"| OBJ["create object"]
|
||||
C -->|"false"| E{"manual_type"}
|
||||
C -->|"false"| E{{"manual_type"}}
|
||||
E -->|"object"| OBJ
|
||||
E -->|"array"| ARR["create array"]
|
||||
D -->|"true"| ARR
|
||||
D -->|"false"| F{"manual_type"}
|
||||
D -->|"false"| F{{"manual_type"}}
|
||||
F -->|"array"| ARR
|
||||
F -->|"object"| ERR["throw type_error.301"]
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Decision flow for an initializer list: hexagons are checks, edge labels are their
|
||||
outcomes, and rectangles are the resulting value or exception.</p>
|
||||
|
||||
The rules aim to create the best fit between a C++ initializer list and JSON values. The rationale is as follows:
|
||||
|
||||
1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object.
|
||||
@@ -482,15 +485,15 @@ basic_json(basic_json&& other) noexcept;
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0.
|
||||
2. Since version 1.0.0.
|
||||
3. Since version 2.1.0.
|
||||
4. Since version 3.2.0. Explicit for different string types if `JSON_USE_IMPLICIT_CONVERSIONS` is `0` since
|
||||
1. Added in version 1.0.0.
|
||||
2. Added in version 1.0.0.
|
||||
3. Added in version 2.1.0.
|
||||
4. Added in version 3.1.2. Explicit for different string types if `JSON_USE_IMPLICIT_CONVERSIONS` is `0` since
|
||||
version 3.13.0.
|
||||
5. Since version 1.0.0.
|
||||
6. Since version 1.0.0.
|
||||
7. Since version 1.0.0. Fixed in version 3.13.0 to also check the iterator range for binary values; before, a range
|
||||
5. Added in version 1.0.0.
|
||||
6. Added in version 1.0.0.
|
||||
7. Added in version 1.0.0. Fixed in version 3.13.0 to also check the iterator range for binary values; before, a range
|
||||
that did not cover the whole value (such as `(end(), end())`) was accepted and the whole binary value was copied,
|
||||
unlike the other primitive types.
|
||||
8. Since version 1.0.0.
|
||||
9. Since version 1.0.0.
|
||||
8. Added in version 1.0.0.
|
||||
9. Added in version 1.0.0.
|
||||
@@ -7,7 +7,12 @@ const_iterator begin() const noexcept;
|
||||
|
||||
Returns an iterator to the first element.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-begin-end.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`begin()` points to the first element and `end()` to the position after the last element;
|
||||
the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -6,7 +6,12 @@ const_iterator cbegin() const noexcept;
|
||||
|
||||
Returns an iterator to the first element.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-begin-end.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`cbegin()` points to the first element, like `begin()`, and `end()` to the position after
|
||||
the last element; the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -6,7 +6,12 @@ const_iterator cend() const noexcept;
|
||||
|
||||
Returns an iterator to one past the last element.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-begin-end.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`cend()` points to the position after the last element, like `end()`, and `begin()` to
|
||||
the first element; the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -141,9 +141,8 @@ Logarithmic in the size of the JSON object.
|
||||
## Version history
|
||||
|
||||
1. Added in version 3.11.0.
|
||||
2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. Fixed in
|
||||
version 3.13.0 to consistently accept `std::string_view`-convertible keys, as already supported by
|
||||
[`operator[]`](operator[].md), [`at`](at.md), [`value`](value.md), and other lookup functions.
|
||||
2. Added in version 3.6.0. Extended template `KeyType` to support comparable types in version 3.11.0. Support for keys
|
||||
convertible to `std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||
3. Added in version 3.7.0.
|
||||
4. Deleted overloads for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
||||
causing undefined behavior at runtime.
|
||||
@@ -92,8 +92,7 @@ Logarithmic in the size of the JSON object.
|
||||
## Version history
|
||||
|
||||
1. Added in version 3.11.0.
|
||||
2. Added in version 1.0.0. Changed parameter `key` type to `KeyType&&` in version 3.11.0. Fixed in version 3.13.0 to
|
||||
consistently accept `std::string_view`-convertible keys, as already supported by [`operator[]`](operator[].md),
|
||||
[`at`](at.md), [`value`](value.md), and other lookup functions.
|
||||
2. Added in version 1.0.0. Changed to support comparable key types in version 3.11.0. Support for keys convertible to
|
||||
`std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||
3. Deleted overload for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
||||
causing undefined behavior at runtime.
|
||||
@@ -6,7 +6,13 @@ const_reverse_iterator crbegin() const noexcept;
|
||||
|
||||
Returns an iterator to the reverse-beginning; that is, the last element.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-rbegin-rend.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`crbegin()` points to the last element, like `rbegin()`, and `rend()` to the position
|
||||
before the first element. The upper row is the reversed sequence and the lower row the forward sequence; dashed arrows
|
||||
link each reverse iterator to the forward iterator it stores, and dashed cells are past-the-last positions.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -7,7 +7,13 @@ const_reverse_iterator crend() const noexcept;
|
||||
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder,
|
||||
attempting to access it results in undefined behavior.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-rbegin-rend.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`crend()` points to the position before the first element, like `rend()`, and `rbegin()`
|
||||
to the last element. The upper row is the reversed sequence and the lower row the forward sequence; dashed arrows link
|
||||
each reverse iterator to the forward iterator it stores, and dashed cells are past-the-last positions.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -69,6 +69,6 @@ Logarithmic in the size of the container, O(log(`size()`)).
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.8.
|
||||
- Added in version 2.0.8.
|
||||
- Fixed in version 3.13.0: for [`ordered_json`](../ordered_json.md), the value could previously only be passed as an
|
||||
rvalue; it can now also be passed as an lvalue or a `#!cpp const` lvalue, matching the behavior of `json`.
|
||||
@@ -67,5 +67,5 @@ Amortized constant.
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.8.
|
||||
- Added in version 2.0.8.
|
||||
- Returns reference since 3.7.0.
|
||||
@@ -7,7 +7,12 @@ const_iterator end() const noexcept;
|
||||
|
||||
Returns an iterator to one past the last element.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-begin-end.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`end()` points to the position after the last element and `begin()` to the first element;
|
||||
the dashed cell is the past-the-last position, which must not be dereferenced.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -213,7 +213,6 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
1. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
||||
2. Added in version 1.0.0. Added support for binary types in version 3.8.0.
|
||||
3. Added in version 1.0.0.
|
||||
4. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
||||
already supported by [`operator[]`](operator[].md), [`at`](at.md), [`value`](value.md), and other lookup
|
||||
functions.
|
||||
4. Added in version 3.11.0. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
||||
across the lookup functions.
|
||||
5. Added in version 1.0.0.
|
||||
@@ -40,6 +40,9 @@ classDiagram
|
||||
style json_exception fill:#CCCCFF
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||
base class, and the highlighted box is `basic_json::exception`.</p>
|
||||
|
||||
Subclasses:
|
||||
|
||||
- [`parse_error`](parse_error.md) for exceptions indicating a parse error
|
||||
@@ -84,4 +87,4 @@ constructor.
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
- Added in version 3.0.0.
|
||||
@@ -99,8 +99,7 @@ Logarithmic in the size of the JSON object.
|
||||
## Version history
|
||||
|
||||
1. Added in version 3.11.0.
|
||||
2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. Fixed in version 3.13.0 to
|
||||
consistently accept `std::string_view`-convertible keys, as already supported by [`operator[]`](operator[].md),
|
||||
[`at`](at.md), [`value`](value.md), and other lookup functions.
|
||||
2. Added in version 1.0.0. Changed to support comparable types in version 3.11.0. Support for keys convertible to
|
||||
`std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||
3. Deleted overloads for integral key types added in version 3.13.0 to reject such calls at compile time instead of
|
||||
causing undefined behavior at runtime.
|
||||
@@ -57,4 +57,4 @@ Constant.
|
||||
## Version history
|
||||
|
||||
- Added in version 1.0.0.
|
||||
- Adjusted code to return reference to binary values in version 3.8.0.
|
||||
- Binary values are supported since version 3.8.0.
|
||||
@@ -188,6 +188,6 @@ overload (3).
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 2.1.0.
|
||||
2. Since version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.2.0.
|
||||
3. Since version 1.0.0.
|
||||
1. Added in version 2.1.0.
|
||||
2. Added in version 2.1.0. Extended to work with other specializations of `basic_json` in version 3.1.2.
|
||||
3. Added in version 1.0.0.
|
||||
@@ -45,7 +45,7 @@ Constant.
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -76,5 +76,5 @@ Depends on the `json_serializer<ValueType>::from_json()` implementation.
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.3.0.
|
||||
- Added in version 3.3.0.
|
||||
- Added a `static_assert` with a clear message for `const` arguments in version 3.13.0.
|
||||
@@ -44,6 +44,22 @@ are collected in [Template Parameter Requirements](../../features/types/template
|
||||
- [**json**](../json.md) - default specialization
|
||||
- [**ordered_json**](../ordered_json.md) - a specialization that maintains the insertion order of object keys
|
||||
|
||||
## Documents and views
|
||||
|
||||
Besides `basic_json`, the library offers a second way to hold a parsed JSON text: a
|
||||
[`basic_json_document`](../basic_json_document/index.md), which owns or borrows the text and holds a flat index of the
|
||||
values in it, and a [`basic_json_view`](../basic_json_view/index.md), a read-only handle to one value of such a document.
|
||||
Both are defined in the header `<nlohmann/json_view.hpp>`; see
|
||||
[Zero-copy JSON views](../../features/json_view.md) for the concept and the trade-offs.
|
||||
|
||||
- [**json_document**](../json_document.md) / [**ordered_json_document**](../ordered_json_document.md) - read-only
|
||||
documents of the `basic_json` specialization they belong to
|
||||
- [**json_editable_document**](../json_editable_document.md) /
|
||||
[**ordered_json_editable_document**](../ordered_json_editable_document.md) - documents that can be modified in place
|
||||
- [**json_view**](../json_view.md) / [**ordered_json_view**](../ordered_json_view.md) - views of a document
|
||||
- [**json_editable_view**](../json_editable_view.md) /
|
||||
[**ordered_json_editable_view**](../ordered_json_editable_view.md) - views of an editable document
|
||||
|
||||
## Iterator invalidation
|
||||
|
||||
All operations that add values to an **array** ([`push_back`](push_back.md) , [`operator+=`](operator+=.md),
|
||||
@@ -343,6 +359,9 @@ Access to the JSON value
|
||||
## See also
|
||||
|
||||
- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259)
|
||||
- [basic_json_document](../basic_json_document/index.md) / [basic_json_view](../basic_json_view/index.md) - parse a JSON
|
||||
text into a flat index and read it through a view
|
||||
- [Zero-copy JSON views](../../features/json_view.md) - when to use a document and a view instead of a `basic_json`
|
||||
|
||||
## Version history
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ classDiagram
|
||||
style json_invalid_iterator fill:#CCCCFF
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||
base class, and the highlighted box is `basic_json::invalid_iterator`.</p>
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
@@ -75,4 +78,4 @@ classDiagram
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
- Added in version 3.0.0.
|
||||
@@ -104,8 +104,8 @@ When iterating over an array, `key()` will return the index of the element as st
|
||||
|
||||
## Version history
|
||||
|
||||
- Added `iterator_wrapper` in version 3.0.0.
|
||||
- Added `items` and deprecated `iterator_wrapper` in version 3.1.0.
|
||||
- Added in version 3.1.0 as the replacement of the static function `iterator_wrapper`, which was available since
|
||||
version 1.0.0 and is deprecated since version 3.1.0.
|
||||
- Added structured binding support in version 3.5.0.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
@@ -51,4 +51,4 @@ deserializes. See [Template Parameter Requirements](../../features/types/templat
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.0.
|
||||
- Added in version 2.1.0.
|
||||
@@ -71,6 +71,6 @@ returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.0.0.
|
||||
- Added in version 3.1.0.
|
||||
- Fixed use of freed or relocated memory when `apply_patch` is `#!cpp *this` or refers to a value contained in
|
||||
`#!cpp *this`, in version 3.13.0.
|
||||
@@ -128,6 +128,6 @@ interpreted as `object_t::value_type` or `std::initializer_list<basic_json>`, se
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0.
|
||||
2. Since version 1.0.0.
|
||||
3. Since version 2.0.0.
|
||||
1. Added in version 1.0.0.
|
||||
2. Added in version 1.0.0.
|
||||
3. Added in version 2.0.0.
|
||||
@@ -284,10 +284,10 @@ Strong exception safety: if an exception occurs, the original value stays intact
|
||||
1. Added in version 1.0.0. Fixed in version 3.13.0 to throw `#!cpp std::length_error` instead of emptying the array and
|
||||
accessing it out of bounds when `idx` equals the maximum value of `size_type`. A missing index in the const version
|
||||
is guarded by a runtime assertion since version 3.13.0.
|
||||
2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. Removed overloads for `T* key` (replaced by 3)
|
||||
in version 3.11.0.
|
||||
3. Added in version 3.11.0. Fixed in version 3.13.0 to consistently accept `std::string_view`-convertible keys, as
|
||||
already supported by [`at`](at.md), [`value`](value.md), [`find`](find.md), and other lookup functions.
|
||||
2. Added in version 1.0.0. Added overloads for `T* key` in version 1.1.0. The `T* key` overloads forward to
|
||||
overload 3 since version 3.11.0.
|
||||
3. Added in version 3.11.0. Support for keys convertible to `std::string_view` added in version 3.13.0, consistently
|
||||
across the lookup functions.
|
||||
4. Added in version 2.0.0. A missing array index in the const version is guarded by a runtime assertion since
|
||||
version 3.13.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109) instead of
|
||||
[`out_of_range.404`](../../home/exceptions.md#jsonexceptionout_of_range404) for a one-character array index that is not
|
||||
|
||||
@@ -89,6 +89,6 @@ Linear in the size of the JSON value.
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 1.0.0.
|
||||
- Added in version 1.0.0.
|
||||
- Macros `JSON_EXPLICIT`/[`JSON_USE_IMPLICIT_CONVERSIONS`](../macros/json_use_implicit_conversions.md) added
|
||||
in version 3.9.0.
|
||||
@@ -40,6 +40,9 @@ classDiagram
|
||||
style json_other_error fill:#CCCCFF
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||
base class, and the highlighted box is `basic_json::other_error`.</p>
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
@@ -75,4 +78,4 @@ classDiagram
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
- Added in version 3.0.0.
|
||||
@@ -41,6 +41,9 @@ classDiagram
|
||||
style json_out_of_range fill:#CCCCFF
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||
base class, and the highlighted box is `basic_json::out_of_range`.</p>
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
@@ -76,4 +79,4 @@ classDiagram
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
- Added in version 3.0.0.
|
||||
@@ -25,6 +25,10 @@ static basic_json parse(IteratorType first, SentinelType last,
|
||||
respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to
|
||||
the iterator type with `operator!=`.
|
||||
|
||||
Ill-formed UTF-16 and UTF-32 sequences are rejected: a lone surrogate, a high surrogate that is not followed by its
|
||||
low surrogate, and a code point above `U+10FFFF` all yield a
|
||||
[`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101).
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
@@ -34,9 +38,12 @@ static basic_json parse(IteratorType first, SentinelType last,
|
||||
- a `FILE` pointer (throws if null)
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters (throws if null)
|
||||
- a `std::string`
|
||||
- a `std::string` or a `std::string_view` (C++17)
|
||||
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
|
||||
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
|
||||
- wide characters (`wchar_t`, `char16_t`, `char32_t`), which are converted to UTF-8: a wide string object
|
||||
(`std::wstring`, `std::u16string`, `std::u32string`) or an array (e.g. a wide string literal); a pointer to a
|
||||
null-terminated wide string (e.g. `std::u16string::c_str()`) is not supported
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type, for instance.
|
||||
@@ -112,6 +119,13 @@ By default, a `'\0'` (NUL) byte anywhere in the input is treated as end of input
|
||||
outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-bytes-in-the-input) for details and the
|
||||
[`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) macro to opt into rejecting it instead.
|
||||
|
||||
!!! tip "Parsing into a document instead of a value"
|
||||
|
||||
[`basic_json_document::parse`](../basic_json_document/parse.md) accepts the same inputs and the same options, but
|
||||
keeps the result as a flat index of the parsed values instead of a tree of `basic_json` values. It is faster and uses
|
||||
less memory when only parts of the document are read, and it also accepts a pointer to a null-terminated wide string,
|
||||
which `parse()` does not. See [Zero-copy JSON views](../../features/json_view.md).
|
||||
|
||||
!!! tip "Performance"
|
||||
|
||||
Contiguous inputs (strings, string views, vectors, arrays, pointer ranges) are the fastest to parse. A
|
||||
@@ -250,6 +264,22 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
|
||||
--8<-- "examples/trailing_commas.output"
|
||||
```
|
||||
|
||||
??? example "Example: parse from UTF-16, UTF-32, and wide strings"
|
||||
|
||||
The encoding is deduced from the character type of the input; `std::u16string` and `std::u32string` are interpreted
|
||||
as UTF-16 and UTF-32, and `std::wstring` uses the platform's `wchar_t` width. String literals like `u"..."`,
|
||||
`U"..."`, and `L"..."` work as well, as do iterators over wide characters.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/parse__wide_string.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/parse__wide_string.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [accept](accept.md) - check if the input is valid JSON
|
||||
@@ -280,6 +310,9 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
|
||||
time).
|
||||
- Parsing from a `FILE*` locks the file once instead of once per character in version 3.13.0
|
||||
([`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) restores `std::fgetc`).
|
||||
- Ill-formed UTF-16 and UTF-32 input (a lone surrogate, a high surrogate that is not followed by its low surrogate, or
|
||||
a code point above `U+10FFFF`) is rejected with `parse_error.101` in version 3.13.0; before that, some such
|
||||
sequences were accepted or ended the input silently.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ classDiagram
|
||||
style json_parse_error fill:#CCCCFF
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||
base class, and the highlighted box is `basic_json::parse_error`.</p>
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
@@ -84,4 +87,4 @@ or the end of file. This also holds true when reading a byte vector for binary f
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
- Added in version 3.0.0.
|
||||
@@ -22,7 +22,12 @@ The parser callback distinguishes the following events:
|
||||
|
||||
## Examples
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/callback_events.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>Each coloured dot marks where the parser reports a `parse_event_t` event while reading
|
||||
the JSON text on the left; the legend on the right names the event per colour.</p>
|
||||
|
||||
??? example
|
||||
|
||||
|
||||
@@ -23,7 +23,12 @@ table describes the values of the parameters `depth`, `event`, and `parsed`.
|
||||
| `parse_event_t::array_end` | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array |
|
||||
| `parse_event_t::value` | the parser finished reading a JSON value | depth of the value | the parsed JSON value |
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/callback_events.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>Parse events for a small JSON text: each coloured dot marks the position at which the
|
||||
parser calls the callback, and the legend on the right names the event per colour.</p>
|
||||
|
||||
Discarding a value (i.e., returning `#!cpp false`) has different effects depending on the context in which function was
|
||||
called:
|
||||
|
||||
@@ -125,6 +125,6 @@ throws.
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0.
|
||||
2. Since version 1.0.0.
|
||||
3. Since version 2.0.0.
|
||||
1. Added in version 1.0.0.
|
||||
2. Added in version 1.0.0.
|
||||
3. Added in version 2.0.0.
|
||||
@@ -7,7 +7,13 @@ const_reverse_iterator rbegin() const noexcept;
|
||||
|
||||
Returns an iterator to the reverse-beginning; that is, the last element.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-rbegin-rend.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`rbegin()` points to the last element and `rend()` to the position before the first
|
||||
element. The upper row is the reversed sequence and the lower row the forward sequence; dashed arrows link each reverse
|
||||
iterator to the forward iterator it stores, and dashed cells are past-the-last positions.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -8,7 +8,13 @@ const_reverse_iterator rend() const noexcept;
|
||||
Returns an iterator to the reverse-end; that is, one before the first element. This element acts as a placeholder,
|
||||
attempting to access it results in undefined behavior.
|
||||
|
||||

|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/range-rbegin-rend.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>`rend()` points to the position before the first element and `rbegin()` to the last
|
||||
element. The upper row is the reversed sequence and the lower row the forward sequence; dashed arrows link each reverse
|
||||
iterator to the forward iterator it stores, and dashed cells are past-the-last positions.</p>
|
||||
|
||||
## Return value
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ Read from input and generate SAX events
|
||||
respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to
|
||||
the iterator type with `operator!=`.
|
||||
|
||||
Ill-formed UTF-16 and UTF-32 sequences are rejected: a lone surrogate, a high surrogate that is not followed by its
|
||||
low surrogate, and a code point above `U+10FFFF` all yield a
|
||||
[`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101).
|
||||
|
||||
The SAX event lister must follow the interface of [`json_sax`](../json_sax/index.md).
|
||||
|
||||
## Template parameters
|
||||
@@ -42,8 +46,12 @@ The SAX event lister must follow the interface of [`json_sax`](../json_sax/index
|
||||
- a `FILE` pointer
|
||||
- a C-style array of characters
|
||||
- a pointer to a null-terminated string of single byte characters
|
||||
- a `std::string` or a `std::string_view` (C++17)
|
||||
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators
|
||||
(as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
|
||||
- wide characters (`wchar_t`, `char16_t`, `char32_t`), which are converted to UTF-8: a wide string object
|
||||
(`std::wstring`, `std::u16string`, `std::u32string`) or an array (e.g. a wide string literal); a pointer to a
|
||||
null-terminated wide string (e.g. `std::u16string::c_str()`) is not supported
|
||||
|
||||
`IteratorType`
|
||||
: a compatible iterator type for overload (2); a pair of character iterators whose `value_type` is an integral type
|
||||
@@ -160,6 +168,9 @@ use the same file with stdio functions, but it must not wait for another thread
|
||||
([`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md)).
|
||||
- Parsing from a `FILE*` locks the file once instead of once per character in version 3.13.0
|
||||
([`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md)).
|
||||
- Ill-formed UTF-16 and UTF-32 input (a lone surrogate, a high surrogate that is not followed by its low surrogate, or
|
||||
a code point above `U+10FFFF`) is rejected with `parse_error.101` in version 3.13.0; before that, some such
|
||||
sequences were accepted or ended the input silently.
|
||||
|
||||
!!! warning "Deprecation"
|
||||
|
||||
|
||||
@@ -182,10 +182,10 @@ Constant.
|
||||
|
||||
## Version history
|
||||
|
||||
1. Since version 1.0.0. Exchanges the `json_base_class_t` subobject along with the value since version 3.13.0.
|
||||
2. Since version 1.0.0. Exchanges the `json_base_class_t` subobject along with the value since version 3.13.0.
|
||||
3. Since version 1.0.0.
|
||||
4. Since version 1.0.0.
|
||||
5. Since version 1.0.0.
|
||||
6. Since version 3.8.0.
|
||||
7. Since version 3.8.0.
|
||||
1. Added in version 1.0.0. Exchanges the `json_base_class_t` subobject along with the value since version 3.13.0.
|
||||
2. Added in version 1.0.0. Exchanges the `json_base_class_t` subobject along with the value since version 3.13.0.
|
||||
3. Added in version 1.0.0.
|
||||
4. Added in version 1.0.0.
|
||||
5. Added in version 1.0.0.
|
||||
6. Added in version 3.8.0.
|
||||
7. Added in version 3.8.0.
|
||||
@@ -124,5 +124,3 @@ Linear in the size of the JSON value `j`.
|
||||
[`JSON_STRICT_BINARY_UTF8`](../macros/json_strict_binary_utf8.md) is enabled) throws `type_error.316`.
|
||||
- Throws `type_error.321` for a discarded value since version 3.13.0; previously, a discarded value nested in an
|
||||
array or object was silently skipped, producing invalid BJData.
|
||||
- Writes unsigned integers wider than 64 bits as high-precision numbers since version 3.13.0; previously, they were
|
||||
silently truncated to 64 bits.
|
||||
@@ -41,6 +41,9 @@ classDiagram
|
||||
style json_type_error fill:#CCCCFF
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Class hierarchy of the library's exceptions; arrows point from a derived class to its
|
||||
base class, and the highlighted box is `basic_json::type_error`.</p>
|
||||
|
||||
## Member functions
|
||||
|
||||
- **what** - returns explanatory string
|
||||
@@ -76,4 +79,4 @@ classDiagram
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 3.0.0.
|
||||
- Added in version 3.0.0.
|
||||
@@ -231,11 +231,8 @@ changes to any JSON value.
|
||||
1. Added in version 1.0.0. Changed parameter `default_value` type from `const ValueType&` to `ValueType&&` in version
|
||||
3.11.0. Deleted overload for integral key types added in version 3.13.0 to reject such calls at compile time
|
||||
instead of causing undefined behavior at runtime.
|
||||
2. Added in version 3.11.0. Made `ValueType` the first template parameter in version 3.11.2. Fixed in version 3.13.0
|
||||
to consistently accept `std::string_view`-convertible keys, as already supported by
|
||||
[`operator[]`](operator[].md), [`at`](at.md), [`find`](find.md), and other lookup functions.
|
||||
3. Added in version 2.0.2. Extended to work with arrays in version 3.13.0, including fixing an issue where resolving
|
||||
`ptr` through an array unexpectedly threw `out_of_range` instead of returning the resolved element (or
|
||||
`default_value`, as documented). Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109)
|
||||
2. Added in version 3.11.0. Made `ValueType` the first template parameter in version 3.11.2. Support for keys
|
||||
convertible to `std::string_view` added in version 3.13.0, consistently across the lookup functions.
|
||||
3. Added in version 2.0.2. Extended to work with arrays in version 3.13.0. Throws [`parse_error.109`](../../home/exceptions.md#jsonexceptionparse_error109)
|
||||
instead of returning `default_value` for a one-character array index that is not a digit (e.g., `/x`) in version
|
||||
3.13.0, as it already did for longer ones.
|
||||
@@ -48,6 +48,9 @@ functions [`is_null`](is_null.md), [`is_object`](is_object.md), [`is_array`](is_
|
||||
F --> G[binary]
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Arrows point from a type to the next greater type in the ordering used by
|
||||
`operator<`.</p>
|
||||
|
||||
!!! note "Types of numbers"
|
||||
|
||||
There are three enumerators for numbers (`number_integer`, `number_unsigned`, and `number_float`) to distinguish
|
||||
|
||||
@@ -9,8 +9,8 @@ class basic_json_document;
|
||||
|
||||
A parsed JSON text, held as a flat index of its values
|
||||
([16 bytes per value](../../home/architecture.md#node-index-of-json-views)) instead of a tree of `BasicJsonType` values.
|
||||
Strings and numbers stay in the source text; only strings that contain escapes are decoded, into one buffer owned by
|
||||
the document. [`basic_json_view`](../basic_json_view/index.md) is a read-only handle to one value of a
|
||||
Strings and floating-point numbers stay in the source text; integers are converted while parsing, and strings that
|
||||
contain escapes are decoded into one buffer owned by the document. [`basic_json_view`](../basic_json_view/index.md) is a read-only handle to one value of a
|
||||
`basic_json_document`; [`materialize()`](../basic_json_view/materialize.md) turns a subtree into the
|
||||
`BasicJsonType` value that [`BasicJsonType::parse()`](../basic_json/parse.md) would have produced for it.
|
||||
|
||||
@@ -115,6 +115,13 @@ points apply to every edit:
|
||||
[`source_offset()`](../basic_json_view/source_offset.md) of a value introduced by an edit is
|
||||
`#!cpp static_cast<std::size_t>(-1)`, the same value it reports for a decoded string.
|
||||
|
||||
## See also
|
||||
|
||||
- [Zero-copy JSON views](../../features/json_view.md) - guide to documents and views
|
||||
- [**basic_json_view**](../basic_json_view/index.md) - the non-owning handle to a value in a document
|
||||
- [**json_document**](../json_document.md) and [**json_editable_document**](../json_editable_document.md) - the default specializations
|
||||
- [**materialize**](../basic_json_view/materialize.md) - build a `basic_json` value from a view
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.13.0.
|
||||
@@ -21,17 +21,19 @@ static basic_json_document parse(IteratorType first, IteratorType last,
|
||||
|
||||
Both overloads accept the same JSON text as [`BasicJsonType::parse()`](../basic_json/parse.md), with the same
|
||||
`ignore_comments`/`ignore_trailing_commas` options, but build a [`basic_json_document`](index.md) (a flat index into
|
||||
the input) instead of a tree of `BasicJsonType` values. They take the same inputs as `BasicJsonType::parse()`. Byte
|
||||
inputs that stay alive can be borrowed; all others (streams, `#!cpp FILE*`, wide characters, non-contiguous
|
||||
iterators) are read into a copy that the document owns -- see the Notes. Use [`parse_copy()`](parse_copy.md) to get an
|
||||
owned copy of a borrowable input as well.
|
||||
the input) instead of a tree of `BasicJsonType` values. They accept every input `BasicJsonType::parse()` takes, and in
|
||||
addition a pointer to a null-terminated wide string (which `BasicJsonType::parse()` rejects). Contiguous inputs of
|
||||
single-byte characters that stay alive can be borrowed; all others (streams, `#!cpp FILE*`, wide characters, which
|
||||
must be converted to UTF-8, and non-contiguous iterators) are read into a copy that the document owns -- see the
|
||||
Notes. Use [`parse_copy()`](parse_copy.md) to get an owned copy of a borrowable input
|
||||
as well.
|
||||
|
||||
## Template parameters
|
||||
|
||||
`InputType`
|
||||
: A compatible input, for instance:
|
||||
|
||||
- a `#!cpp std::string`, `#!cpp std::string_view`, or a C-style array of single-byte characters
|
||||
- a `#!cpp std::string`, a `#!cpp std::string_view` (C++17), or a C-style array of single-byte characters
|
||||
- a pointer to a null-terminated string of single-byte characters (`#!cpp char`, `#!cpp signed char`,
|
||||
`#!cpp unsigned char`, `#!cpp std::uint8_t`)
|
||||
- a container for which `#!cpp obj.data()` and `#!cpp obj.size()` give contiguous single-byte access, e.g.
|
||||
@@ -47,6 +49,10 @@ owned copy of a borrowable input as well.
|
||||
`#!cpp std::string::iterator`; the iterators of single-byte characters are borrowed or read like the byte inputs
|
||||
above, those of wide characters are converted to UTF-8
|
||||
|
||||
Ill-formed UTF-16 and UTF-32 sequences are rejected: a lone surrogate, a high surrogate that is not followed by its low
|
||||
surrogate, and a code point above `U+10FFFF` all yield a
|
||||
[`parse_error.101`](../../home/exceptions.md#jsonexceptionparse_error101).
|
||||
|
||||
## Parameters
|
||||
|
||||
`input` (in)
|
||||
@@ -155,3 +161,5 @@ buffer of a given length, pass a pair of pointers: `#!cpp parse(ptr, ptr + len)`
|
||||
## Version history
|
||||
|
||||
- Added in version 3.13.0.
|
||||
- Ill-formed UTF-16 and UTF-32 input (a lone surrogate, a high surrogate that is not followed by its low surrogate, or
|
||||
a code point above `U+10FFFF`) is rejected with `parse_error.101`.
|
||||
@@ -80,7 +80,8 @@ None of these exceptions carry a [`JSON_DIAGNOSTICS`](../macros/json_diagnostics
|
||||
Objects with 128 or more members get a hash index of their keys while parsing, so that a lookup in them takes
|
||||
constant time on average.
|
||||
2. Linear in `idx`: elements are skipped one at a time from the first one, since they are not a fixed size in the
|
||||
index (unlike `BasicJsonType`'s array, which is random-access).
|
||||
index (unlike `BasicJsonType`'s array, which is random-access). Constant if no element of the array is an array
|
||||
or object, since the elements are then adjacent in the index.
|
||||
3. Linear in the number of reference tokens of `ptr` and, for each token, in the number of members of the object at
|
||||
that level (as 1.) or the index into the array (as 2.).
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ This exception does not carry a [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.
|
||||
|
||||
Linear in the size of the array or object: unlike [`front()`](front.md), which only ever looks at the first
|
||||
element, `back()` has to walk every element to find where they end, since elements are not a fixed size in the
|
||||
index.
|
||||
index. Constant if no element of the array is an array or object, since the elements are then adjacent
|
||||
in the index.
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
@@ -143,6 +143,13 @@ still refers to it -- including ones taken before the change -- reads the new va
|
||||
|
||||
- [**source_offset**](source_offset.md) - byte offset of this value in the document's source text
|
||||
|
||||
## See also
|
||||
|
||||
- [Zero-copy JSON views](../../features/json_view.md) - guide to documents and views
|
||||
- [**basic_json_document**](../basic_json_document/index.md) - the document that owns the parsed data
|
||||
- [**json_view**](../json_view.md) and [**json_editable_view**](../json_editable_view.md) - the default specializations
|
||||
- [**materialize**](materialize.md) - build a `basic_json` value from a view
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.13.0.
|
||||
@@ -86,7 +86,8 @@ None of these exceptions carry a [`JSON_DIAGNOSTICS`](../macros/json_diagnostics
|
||||
Objects with 128 or more members get a hash index of their keys while parsing, so that a lookup in them takes
|
||||
constant time on average.
|
||||
2. Linear in `idx`: elements are skipped one at a time from the first one, since they are not a fixed size in the
|
||||
index (unlike `BasicJsonType`'s array, which is random-access).
|
||||
index (unlike `BasicJsonType`'s array, which is random-access). Constant if no element of the array is an array
|
||||
or object, since the elements are then adjacent in the index.
|
||||
3. Linear in the number of reference tokens of `ptr` and, for each token, in the number of members of the object at
|
||||
that level (as 1.) or the index into the array (as 2.).
|
||||
|
||||
|
||||
@@ -51,4 +51,4 @@ byte_container_with_subtype(container_type&& container, subtype_type subtype);
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.8.0.
|
||||
Added in version 3.8.0.
|
||||
@@ -39,4 +39,4 @@ Constant.
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.8.0.
|
||||
Added in version 3.8.0.
|
||||
@@ -42,4 +42,4 @@ Constant.
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.8.0.
|
||||
Added in version 3.8.0.
|
||||
@@ -29,6 +29,14 @@ specific naming scheme in order to override the binary type.
|
||||
- [**has_subtype**](has_subtype.md) - return whether the value has a subtype
|
||||
- [**clear_subtype**](clear_subtype.md) - clears the binary subtype
|
||||
|
||||
## See also
|
||||
|
||||
- [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
|
||||
- [**binary**](../basic_json/binary.md) - create a binary array value
|
||||
- [**get_binary**](../basic_json/get_binary.md) - get a reference to the stored binary value
|
||||
- [**binary_t**](../basic_json/binary_t.md) - type for binary arrays
|
||||
- [Binary formats](../../features/binary_formats/index.md) - formats that can store binary values
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.8.0.
|
||||
|
||||
@@ -44,4 +44,4 @@ Constant.
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.8.0.
|
||||
Added in version 3.8.0.
|
||||
@@ -30,4 +30,4 @@ types.
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 1.0.0.
|
||||
Added in version 1.0.0.
|
||||
@@ -32,4 +32,4 @@ specialization.
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -40,4 +40,4 @@ parsing, without ever rewriting the source text -- see [Edits](basic_json_docume
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -38,4 +38,4 @@ still referring to it seeing the change, see [Edits](basic_json_document/index.m
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -36,6 +36,9 @@ flowchart LR
|
||||
parent["parent_pointer() returns /a/b"] -.-> B
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Boxes are the reference tokens in order; dotted arrows show which token each member
|
||||
function reads, removes, or adds to.</p>
|
||||
|
||||
The diagram shows the reference tokens of the JSON pointer `/a/b/c`.
|
||||
|
||||
## Member types
|
||||
|
||||
@@ -51,5 +51,5 @@ operator string_t() const
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.0.
|
||||
- Added in version 2.0.0.
|
||||
- Changed type to `string_t` and deprecated in version 3.11.0.
|
||||
@@ -49,5 +49,5 @@ ptr == json_pointer(ptr.to_string());
|
||||
|
||||
## Version history
|
||||
|
||||
- Since version 2.0.0.
|
||||
- Added in version 2.0.0.
|
||||
- Changed return type to `string_t` in version 3.11.0.
|
||||
@@ -25,6 +25,9 @@ sequenceDiagram
|
||||
P->>H: end_object()
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>Each arrow is one call from the parser to the SAX handler, from top to bottom in the
|
||||
order the calls happen.</p>
|
||||
|
||||
Note `elements` is passed as `#!cpp std::numeric_limits<std::size_t>::max()` (i.e., "unknown") for JSON text input;
|
||||
only binary formats such as CBOR or MessagePack may report the actual number of elements in `start_object`/
|
||||
`start_array`. Also note that `1` is reported via `number_unsigned` rather than `number_integer` because it has no
|
||||
@@ -59,6 +62,13 @@ leading `-` sign.
|
||||
- [**start_object**](start_object.md) (_virtual_) - the beginning of an object was read
|
||||
- [**string**](string.md) (_virtual_) - a string value was read
|
||||
|
||||
## See also
|
||||
|
||||
- [SAX interface](../../features/parsing/sax_interface.md) - guide to event-based parsing
|
||||
- [**sax_parse**](../basic_json/sax_parse.md) - generate SAX events from an input
|
||||
- [**parse**](../basic_json/parse.md) - DOM parsing, with optional [parser callbacks](../../features/parsing/parser_callbacks.md)
|
||||
- [Parse exceptions](../../features/parsing/parse_exceptions.md)
|
||||
|
||||
## Version history
|
||||
|
||||
- Added in version 3.2.0.
|
||||
|
||||
@@ -31,4 +31,4 @@ This type is a [`basic_json_view`](basic_json_view/index.md) of a value of a [`j
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -137,4 +137,13 @@ header. See also the [macro overview page](../../features/macros.md).
|
||||
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_WITH_DEFAULT_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize/deserialize
|
||||
a derived class; uses default values; uses custom names
|
||||
- [**NLOHMANN_DEFINE_DERIVED_TYPE_NON_INTRUSIVE_ONLY_SERIALIZE_WITH_NAMES**](nlohmann_define_type_with_names.md) - serialize a derived
|
||||
class; uses custom names
|
||||
class; uses custom names
|
||||
|
||||
## See also
|
||||
|
||||
- [Macros](../../features/macros.md) - guide to the supported macros
|
||||
- [Runtime assertions](../../features/assertions.md)
|
||||
- [Arbitrary type conversions](../../features/arbitrary_types.md) - using the `NLOHMANN_DEFINE_TYPE_*` macros
|
||||
- [Enum conversion](../../features/enum_conversion.md) - using `NLOHMANN_JSON_SERIALIZE_ENUM`
|
||||
- [The `nlohmann` namespace](../../features/namespace.md)
|
||||
- [CMake integration](../../integration/cmake.md) - setting macros from the build system
|
||||
@@ -38,7 +38,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -64,7 +64,7 @@ Therefore, assertions can be switched off by defining `NDEBUG`.
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -98,7 +98,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
#define JSON_BRACE_INIT_COPY_SEMANTICS 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ The default value is `0` (disabled, the deprecated functions can still be called
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
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
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ The default value is `0`.
|
||||
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
enum class Choice
|
||||
{
|
||||
@@ -66,7 +66,7 @@ The default value is `0`.
|
||||
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
enum class Choice
|
||||
{
|
||||
@@ -99,7 +99,7 @@ The default value is `0`.
|
||||
#define JSON_DISABLE_ENUM_SERIALIZATION 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
enum class Choice
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ The default value is `0`: streams are scanned in bulk.
|
||||
#include <sstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -115,7 +115,7 @@ The default value is `0`: streams are scanned in bulk.
|
||||
#include <sstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -72,7 +72,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -89,7 +89,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
#define JSON_DISABLE_TUPLE_REFERENCE_CONVERSION 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
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 <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
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 <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@ By default, `#!cpp JSON_NO_SIMD` is not defined, and vector instructions are use
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
#include <sstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -115,7 +115,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
#include <sstream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ The default value is `0` (disabled, the behavior of version 3.12.0 and earlier i
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
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
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
```cpp
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -109,7 +109,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
#define JSON_STRICT_NUL_HANDLING 1
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ The default value is `0` (disabled — existing behavior is preserved).
|
||||
#include <map>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
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 <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
using nlohmann::json;
|
||||
|
||||
enum TaskState { TS_STOPPED, TS_RUNNING, TS_COMPLETED };
|
||||
|
||||
|
||||
@@ -42,4 +42,4 @@ parsing an object of `n` keys costs O(n²) rather than O(n log n). See
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.9.0.
|
||||
Added in version 3.9.0.
|
||||
@@ -35,4 +35,4 @@ of object keys, instead of sorting them like [`json_document`](json_document.md)
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -44,4 +44,4 @@ members [`set`](basic_json_document/set.md) added -- instead of sorting them lik
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -37,4 +37,4 @@ This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -32,4 +32,4 @@ This type is a [`basic_json_view`](basic_json_view/index.md) of a value of an
|
||||
|
||||
## Version history
|
||||
|
||||
Since version 3.13.0.
|
||||
Added in version 3.13.0.
|
||||
@@ -41,6 +41,8 @@ flowchart LR
|
||||
E --> F[Trusted caller]
|
||||
```
|
||||
|
||||
<p class="nj-caption" markdown>The trust boundary: untrusted input enters on the left through the parser, the SAX interface, or the binary readers, and only a value tree reaches the trusted caller on the right.</p>
|
||||
|
||||
## Secure design
|
||||
|
||||
- **Strict parsing.** The parser accepts exactly the JSON grammar of [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259).
|
||||
|
||||
@@ -4,6 +4,15 @@ Ensuring quality is paramount for this project, particularly because [numerous o
|
||||
depend on it. Each commit to the library undergoes rigorous checks against the following requirements, and any
|
||||
violations will result in a failed build.
|
||||
|
||||
The overview shows the checks a change passes on its way from a push or pull request to a release; the sections below
|
||||
describe each of them.
|
||||
|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/qa_pipeline.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>The checks grouped by the stage at which they run, from push or pull request through the merge into develop to a release. The badge on each card says whether the check runs on every push or PR, on a schedule, or continuously.</p>
|
||||
|
||||
## C++ language compliance and compiler compatibility
|
||||
|
||||
!!! success "Requirement: Compiler support"
|
||||
@@ -188,10 +197,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 [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 89 enabled
|
||||
rules.
|
||||
- [x] The code is checked with the latest [Clang Static Analyzer](https://clang-analyzer.llvm.org) with 52 enabled
|
||||
checkers.
|
||||
- [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 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
|
||||
|
||||
@@ -204,6 +216,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 [Sanitizers](https://github.com/google/sanitizers) (address sanitizer, undefined
|
||||
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
|
||||
|
||||
@@ -223,6 +237,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.
|
||||
- [x] Third-party code included in the repository for testing, such as [doctest](https://github.com/doctest/doctest),
|
||||
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
|
||||
|
||||
@@ -258,4 +274,21 @@ Note: Some modern features (like C++20 ranges or filesystem support) may be disa
|
||||
- [x] The library is tested against relevant CMake versions:
|
||||
- CMake 3.5 (the earliest supported)
|
||||
- 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.
|
||||
@@ -58,7 +58,7 @@ particular, a 3.x release does not:
|
||||
- remove or rename a documented macro, CMake option, CMake target, or header, or change what a documented macro does.
|
||||
|
||||
Exceptions to these rules, for instance when fixing a bug requires changing the exception a function throws, are
|
||||
documented in the [release notes](../home/releases.md).
|
||||
documented in the [release notes](../home/releases/index.md).
|
||||
|
||||
The following are **not** part of the public API and may change in any release, including patch releases:
|
||||
|
||||
@@ -91,6 +91,14 @@ Version 4.0 is therefore the sum of these macros: you can try it on the 3.x rele
|
||||
to its 4.0 value and fixing what no longer compiles or behaves differently. Once your code works with all of them, it
|
||||
is ready for version 4.0.
|
||||
|
||||
Each macro has a default value in 3.x and a different value in version 4.0. Define the macro to the 4.0 value to try it on the 3.x release train today; version 4.0 makes that value the default:
|
||||
|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/roadmap_lanes.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>Each row is one macro: the 3.x release that added it, its default in 3.x, and its value in version 4.0 (highlighted) or "removed". Versions on the 3.x lane are not to scale.</p>
|
||||
|
||||
The following macros guard changes that are planned to become the default in version 4.0:
|
||||
|
||||
| Macro | 3.x default | 4.0 behavior | CMake option | Added |
|
||||
@@ -105,6 +113,8 @@ The following macros guard changes that are planned to become the default in ver
|
||||
| [`JSON_DISABLE_TUPLE_REFERENCE_CONVERSION`](../api/macros/json_disable_tuple_reference_conversion.md) | `0` | `1`: a `basic_json` value can no longer be created from a one-element tuple of a reference to it, such as `std::forward_as_tuple(j)`| [`JSON_DisableTupleReferenceConversion`](../integration/cmake.md#json_disabletuplereferenceconversion) | 3.13.0 |
|
||||
| [`JSON_DELETE_DEPRECATED_FUNCTIONS`](../api/macros/json_delete_deprecated_functions.md) | `0` | removed: the deprecated functions are removed (see below); the `from_*(ptr, len)` overloads stay deleted | [`JSON_DeleteDeprecatedFunctions`](../integration/cmake.md#json_deletedeprecatedfunctions) | 3.13.0 |
|
||||
|
||||
<p class="nj-table-caption" markdown>Opt-in macros for the version 4.0 behavior. "3.x default" is the value the library uses when the macro is not defined, "Added" is the release that introduced the macro, and – means there is no CMake option.</p>
|
||||
|
||||
For example, the following makes a 3.x release behave like version 4.0 with respect to these changes:
|
||||
|
||||
```cpp
|
||||
@@ -146,6 +156,8 @@ to the `strict` parameter.
|
||||
| Comparing a [`json_pointer`](../api/json_pointer/index.md) with a string via [`operator==`](../api/json_pointer/operator_eq.md) or [`operator!=`](../api/json_pointer/operator_ne.md) | 3.11.2 | [JSON Pointers](../integration/migration_guide.md#json-pointers) |
|
||||
| [`from_bjdata`](../api/basic_json/from_bjdata.md) and [`from_bon8`](../api/basic_json/from_bon8.md) with `(ptr, len)` | 3.13.0 | [Parsing](../integration/migration_guide.md#parsing) |
|
||||
|
||||
<p class="nj-table-caption" markdown>Deprecated functions, with the release that deprecated each one and the section of the migration guide that shows its replacement.</p>
|
||||
|
||||
The deprecated legacy comparison of discarded values is controlled by a macro and therefore listed in the table above.
|
||||
|
||||
New breaking changes will follow the same path: they are added to these tables when they land in a 3.x release.
|
||||
@@ -0,0 +1,782 @@
|
||||
/* nlohmann/json brand for Material for MkDocs (values from brand/kit/tokens.css) */
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("fonts/Inter.woff2") format("woff2");
|
||||
font-weight: 100 900;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
src: url("fonts/Inter-Italic.woff2") format("woff2");
|
||||
font-style: italic;
|
||||
font-weight: 100 900;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "JetBrains Mono";
|
||||
src: url("fonts/JetBrainsMono.woff2") format("woff2");
|
||||
font-weight: 100 800;
|
||||
font-display: swap;
|
||||
}
|
||||
@font-face {
|
||||
font-family: "JetBrains Mono";
|
||||
src: url("fonts/JetBrainsMono-Italic.woff2") format("woff2");
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
:root {
|
||||
--md-text-font: "Inter";
|
||||
--md-code-font: "JetBrains Mono";
|
||||
}
|
||||
|
||||
/* light */
|
||||
[data-md-color-scheme="default"] {
|
||||
--nj-blue: #1747a6;
|
||||
--nj-blue-deep: #10357d;
|
||||
--nj-blue-soft: #eaf1fd;
|
||||
--nj-band: #1747a6;
|
||||
--nj-red: #d93a3f;
|
||||
--nj-red-soft: #fdeced;
|
||||
--nj-string: #b4322a;
|
||||
--nj-comment: #646d7a;
|
||||
|
||||
--md-primary-fg-color: var(--nj-band);
|
||||
--md-primary-fg-color--light: #1d55c4;
|
||||
--md-primary-fg-color--dark: #10357d;
|
||||
--md-accent-fg-color: var(--nj-blue-deep);
|
||||
--md-accent-fg-color--transparent: rgba(23, 71, 166, .1);
|
||||
--md-typeset-a-color: var(--nj-blue);
|
||||
--md-default-fg-color: #0f1419;
|
||||
--md-default-fg-color--light: #4a515c;
|
||||
--md-default-fg-color--lighter: #8a919c;
|
||||
--md-default-fg-color--lightest: #e3e6eb;
|
||||
--md-typeset-color: #0f1419;
|
||||
--md-code-bg-color: #f5f7fa;
|
||||
--md-code-fg-color: #0f1419;
|
||||
}
|
||||
|
||||
/* dark */
|
||||
[data-md-color-scheme="slate"] {
|
||||
--nj-blue: #7aa7f5;
|
||||
--nj-blue-deep: #a9c6f8;
|
||||
--nj-blue-soft: #16233b;
|
||||
--nj-band: #173e8c;
|
||||
--nj-red: #f06a6e;
|
||||
--nj-red-soft: #3a1c1e;
|
||||
--nj-string: #f08a7e;
|
||||
--nj-comment: #8b929e;
|
||||
|
||||
--md-hue: 220;
|
||||
--md-primary-fg-color: var(--nj-band);
|
||||
--md-primary-fg-color--light: #163f93;
|
||||
--md-primary-fg-color--dark: #0c2556;
|
||||
--md-accent-fg-color: var(--nj-blue-deep);
|
||||
--md-accent-fg-color--transparent: rgba(122, 167, 245, .12);
|
||||
--md-typeset-a-color: var(--nj-blue);
|
||||
--md-default-bg-color: #0f1218;
|
||||
--md-default-fg-color: #f2f4f7;
|
||||
--md-default-fg-color--light: #b3b9c4;
|
||||
--md-default-fg-color--lighter: #7b828e;
|
||||
--md-default-fg-color--lightest: #272c36;
|
||||
--md-typeset-color: #f2f4f7;
|
||||
--md-code-bg-color: #171b23;
|
||||
--md-code-fg-color: #f2f4f7;
|
||||
--md-footer-bg-color: #0b0e13;
|
||||
--md-footer-bg-color--dark: #08090d;
|
||||
}
|
||||
|
||||
/* syntax colours (all at least 4.5:1 on the code panel in both schemes) */
|
||||
[data-md-color-scheme="default"] {
|
||||
--nj-hl-keyword: #1747a6;
|
||||
--nj-hl-type: #0d6e72;
|
||||
--nj-hl-function: #6b3fb8;
|
||||
--nj-hl-string: #23793a;
|
||||
--nj-hl-escape: #0f5d2a;
|
||||
--nj-hl-key: #10357d;
|
||||
--nj-hl-number: #b04a07;
|
||||
--nj-hl-preproc: #a3247a;
|
||||
}
|
||||
[data-md-color-scheme="slate"] {
|
||||
--nj-hl-keyword: #7aa7f5;
|
||||
--nj-hl-type: #4fd1c5;
|
||||
--nj-hl-function: #c4a3ff;
|
||||
--nj-hl-string: #7ed491;
|
||||
--nj-hl-escape: #b2ecc0;
|
||||
--nj-hl-key: #a9c6f8;
|
||||
--nj-hl-number: #f5a65b;
|
||||
--nj-hl-preproc: #f48fc8;
|
||||
}
|
||||
.md-typeset .highlight :is(.k, .kd, .kn, .kr, .kp, .kv, .ow) { color: var(--nj-hl-keyword); font-weight: 600; }
|
||||
.md-typeset .highlight :is(.kt, .nc, .nn, .na) { color: var(--nj-hl-type); }
|
||||
.md-typeset .highlight :is(.nf, .fm, .nb, .bp) { color: var(--nj-hl-function); }
|
||||
.md-typeset .highlight :is(.s, .s1, .s2, .sb, .sc, .sd, .sh, .sx, .sr, .ss, .sa, .dl, .cpf) { color: var(--nj-hl-string); }
|
||||
.md-typeset .highlight :is(.se, .si) { color: var(--nj-hl-escape); font-weight: 600; }
|
||||
.md-typeset .highlight .nt { color: var(--nj-hl-key); }
|
||||
.md-typeset .highlight :is(.m, .mi, .mf, .mh, .mo, .mb, .il, .kc) { color: var(--nj-hl-number); }
|
||||
.md-typeset .highlight .kc { font-weight: 500; }
|
||||
.md-typeset .highlight .cp { color: var(--nj-hl-preproc); }
|
||||
.md-typeset .highlight :is(.c, .c1, .cm, .ch, .cs) { color: var(--nj-comment); font-style: italic; }
|
||||
.md-typeset .highlight :is(.o, .p) { color: var(--md-default-fg-color--light); }
|
||||
.md-typeset .highlight :is(.n, .nx, .nv, .no, .ni, .nl, .py) { color: var(--md-code-fg-color); }
|
||||
.md-typeset .highlight .err { color: inherit; background: none; }
|
||||
|
||||
/* typography: Inter with cv11/ss03, bold headlines with negative tracking */
|
||||
body {
|
||||
font-feature-settings: "cv11", "ss03";
|
||||
}
|
||||
.md-typeset {
|
||||
font-size: .85rem; /* 17 px body */
|
||||
line-height: 1.65;
|
||||
}
|
||||
.md-typeset h1 {
|
||||
color: var(--md-typeset-color);
|
||||
font-weight: 800;
|
||||
letter-spacing: -.035em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
.md-typeset h2 {
|
||||
font-weight: 800;
|
||||
letter-spacing: -.025em;
|
||||
line-height: 1.15;
|
||||
}
|
||||
.md-typeset h3 {
|
||||
font-weight: 700;
|
||||
letter-spacing: -.015em;
|
||||
}
|
||||
.md-typeset table:not([class]) {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* header and tabs: one blue band with the faint syntax pattern; wordmark instead of the site name.
|
||||
A veil over the tile keeps the glyphs from running through the navigation text; the hero shows the pattern at full strength. */
|
||||
.md-header, .md-tabs {
|
||||
--nj-veil: linear-gradient(color-mix(in srgb, var(--md-primary-fg-color) 62%, transparent), color-mix(in srgb, var(--md-primary-fg-color) 62%, transparent));
|
||||
background-color: var(--md-primary-fg-color);
|
||||
background-image: var(--nj-veil), url("pattern-on-blue.svg");
|
||||
background-size: auto, 160px 160px;
|
||||
background-position: 0 0, 0 0;
|
||||
}
|
||||
.md-tabs {
|
||||
background-position: 0 0, 0 -48px; /* continue the header's tile */
|
||||
}
|
||||
.md-header__button.md-logo img {
|
||||
width: auto;
|
||||
height: 1.5rem;
|
||||
}
|
||||
.md-header__topic:first-child .md-ellipsis { /* the wordmark replaces the site name at every width */
|
||||
display: none;
|
||||
}
|
||||
@media screen and (max-width: 76.234375em) { /* Material hides the header logo here: show the wordmark on phones, too */
|
||||
.md-header__button.md-logo {
|
||||
display: block;
|
||||
margin: 0 0 0 .2rem;
|
||||
padding: .4rem .2rem;
|
||||
}
|
||||
.md-header__button[for="__drawer"] {
|
||||
order: -1;
|
||||
}
|
||||
}
|
||||
.md-nav__button.md-logo img {
|
||||
width: auto;
|
||||
height: 1.4rem;
|
||||
}
|
||||
|
||||
/* shapes: 6 px corners on blocks, 4 px on inline code */
|
||||
.md-typeset pre > code, .md-typeset .highlight, .md-typeset .highlighttable,
|
||||
.md-typeset .admonition, .md-typeset details, .md-typeset .tabbed-set,
|
||||
.md-typeset .grid.cards > ul > li, .md-typeset .md-button {
|
||||
border-radius: 6px;
|
||||
}
|
||||
.md-typeset code {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
/* inline code: the font alone marks it, no grey box; linked code keeps the link colour */
|
||||
.md-typeset :not(pre) > code {
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
box-shadow: none;
|
||||
color: inherit;
|
||||
font-size: .88em;
|
||||
}
|
||||
.md-typeset .highlight pre > code, .md-typeset .highlighttable {
|
||||
border: 1px solid var(--md-default-fg-color--lightest);
|
||||
}
|
||||
|
||||
/* callouts: 3 px left border; note/info/tip in blue on blue-soft, danger/bug in red on red-soft */
|
||||
.md-typeset .admonition, .md-typeset details {
|
||||
border-width: 0 0 0 3px;
|
||||
box-shadow: none;
|
||||
font-size: .8rem;
|
||||
}
|
||||
.md-typeset :is(.admonition, details):is(.note, .info, .tip, .abstract, .example, .question) {
|
||||
border-color: var(--nj-blue);
|
||||
background-color: var(--nj-blue-soft);
|
||||
}
|
||||
.md-typeset :is(.note, .info, .tip, .abstract, .example, .question) > :is(.admonition-title, summary) {
|
||||
background-color: transparent;
|
||||
}
|
||||
.md-typeset :is(.note, .info, .tip, .abstract, .example, .question) > :is(.admonition-title, summary)::before {
|
||||
background-color: var(--nj-blue);
|
||||
}
|
||||
.md-typeset :is(.admonition, details):is(.danger, .bug, .failure) {
|
||||
border-color: var(--nj-red);
|
||||
background-color: var(--nj-red-soft);
|
||||
}
|
||||
.md-typeset :is(.danger, .bug, .failure) > :is(.admonition-title, summary) {
|
||||
background-color: transparent;
|
||||
}
|
||||
.md-typeset :is(.danger, .bug, .failure) > :is(.admonition-title, summary)::before {
|
||||
background-color: var(--nj-red);
|
||||
}
|
||||
|
||||
/* buttons */
|
||||
.md-typeset .md-button--primary {
|
||||
background-color: var(--nj-blue);
|
||||
border-color: var(--nj-blue);
|
||||
}
|
||||
|
||||
/* home page hero (overrides/home.html): blue band with the syntax pattern, headline, lead, buttons, code panel */
|
||||
.nj-hero {
|
||||
--nj-hero-to: #123a8a;
|
||||
color: #fff;
|
||||
background-color: var(--md-primary-fg-color);
|
||||
background-image: url("pattern-on-blue.svg"), linear-gradient(160deg, var(--md-primary-fg-color), var(--nj-hero-to));
|
||||
background-size: 160px 160px, auto;
|
||||
background-position: 0 -96px, 0 0; /* continue the tile of header and tabs */
|
||||
}
|
||||
[data-md-color-scheme="slate"] .nj-hero {
|
||||
--nj-hero-to: #0c2556;
|
||||
}
|
||||
.nj-hero__inner {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
|
||||
gap: 2.4rem;
|
||||
align-items: center;
|
||||
padding: 3rem .8rem 3.6rem;
|
||||
}
|
||||
.nj-hero__kicker {
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
padding: .15rem .55rem;
|
||||
border: 1px solid rgba(255, 255, 255, .35);
|
||||
border-radius: 4px;
|
||||
color: #bcd3fb;
|
||||
font-family: var(--md-code-font-family);
|
||||
font-size: .65rem; /* 13 px */
|
||||
font-weight: 500;
|
||||
letter-spacing: .02em;
|
||||
}
|
||||
.nj-hero__title {
|
||||
margin: 0 0 .8rem;
|
||||
color: #fff;
|
||||
font-size: clamp(1.7rem, 4.2vw, 3.2rem); /* 34-64 px */
|
||||
font-weight: 800;
|
||||
line-height: 1.02;
|
||||
letter-spacing: -.035em;
|
||||
}
|
||||
.nj-hero__title span {
|
||||
color: #bcd3fb;
|
||||
}
|
||||
.nj-hero__lead {
|
||||
max-width: 22em;
|
||||
margin: 0 0 2rem;
|
||||
color: rgba(255, 255, 255, .9);
|
||||
font-size: clamp(1.1rem, 2.2vw, 1.6rem); /* 22-32 px */
|
||||
font-style: italic;
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
letter-spacing: -.015em;
|
||||
}
|
||||
.nj-hero__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: .6rem;
|
||||
margin: 0;
|
||||
}
|
||||
.nj-hero .md-button.nj-hero__button {
|
||||
margin: 0;
|
||||
padding: .55em 1.3em;
|
||||
border: 1px solid rgba(255, 255, 255, .6);
|
||||
border-radius: 6px;
|
||||
color: #fff;
|
||||
font-size: .75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.nj-hero .md-button--primary.nj-hero__button {
|
||||
border-color: #fff;
|
||||
background-color: #fff;
|
||||
color: var(--md-primary-fg-color);
|
||||
}
|
||||
.nj-hero .md-button.nj-hero__button:is(:hover, :focus) {
|
||||
border-color: #fff;
|
||||
background-color: rgba(255, 255, 255, .12);
|
||||
color: #fff;
|
||||
}
|
||||
.nj-hero .md-button--primary.nj-hero__button:is(:hover, :focus) {
|
||||
background-color: #eaf1fd;
|
||||
color: var(--md-primary-fg-color);
|
||||
}
|
||||
.nj-hero__code {
|
||||
border-radius: 6px;
|
||||
background-color: var(--md-code-bg-color);
|
||||
box-shadow: 0 12px 32px rgba(5, 18, 48, .35);
|
||||
}
|
||||
.nj-hero__code pre {
|
||||
margin: 0;
|
||||
padding: 1.1rem 1.3rem;
|
||||
overflow-x: auto;
|
||||
color: var(--md-code-fg-color);
|
||||
font-family: var(--md-code-font-family);
|
||||
font-size: .7rem; /* 14 px */
|
||||
line-height: 1.7;
|
||||
}
|
||||
.nj-hero__code .nj-k { color: var(--nj-hl-type); }
|
||||
.nj-hero__code .nj-s { color: var(--nj-hl-string); }
|
||||
.nj-hero__code .nj-n { color: var(--nj-hl-number); }
|
||||
.nj-hero__code .nj-c { color: var(--nj-comment); font-style: italic; }
|
||||
@media screen and (max-width: 59.984375em) {
|
||||
.nj-hero__inner {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 1.8rem;
|
||||
padding: 2rem .8rem 2.4rem;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 29.984375em) {
|
||||
.nj-hero__code pre {
|
||||
font-size: .6rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* the hero carries the headline: keep the page's h1 for the title and screen readers only */
|
||||
body:has(.nj-hero) .md-content__inner > h1 {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0 0 0 0);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* cards: 1 px line border, 6 px corners, blue icon on soft blue, blue border on hover */
|
||||
.md-typeset .grid.cards > ul > li {
|
||||
padding: 1rem 1.1rem;
|
||||
border: 1px solid var(--md-default-fg-color--lightest);
|
||||
background-color: var(--md-default-bg-color);
|
||||
transition: border-color 150ms, box-shadow 150ms, transform 150ms;
|
||||
}
|
||||
.md-typeset .grid.cards > ul > li:is(:hover, :focus-within) {
|
||||
border-color: var(--nj-blue);
|
||||
box-shadow: 0 6px 18px rgba(23, 71, 166, .12);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.md-typeset .grid.cards > ul > li > hr {
|
||||
display: none;
|
||||
}
|
||||
.md-typeset .grid.cards .twemoji.lg {
|
||||
box-sizing: content-box;
|
||||
margin-right: .5rem;
|
||||
padding: .3rem;
|
||||
border-radius: 6px;
|
||||
background-color: var(--nj-blue-soft);
|
||||
color: var(--nj-blue);
|
||||
}
|
||||
.md-typeset .grid.cards > ul > li > p:first-child strong {
|
||||
font-size: .9rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -.01em;
|
||||
}
|
||||
.md-typeset .grid.cards > ul > li > p:last-child a {
|
||||
font-weight: 600;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.md-typeset .grid.cards > ul > li { transition: none; transform: none !important; }
|
||||
}
|
||||
|
||||
/* home page: no table of contents, so keep the text at reading width and the cards in three columns */
|
||||
body:has(.nj-hero) .md-content {
|
||||
max-width: 58rem;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@media screen and (min-width: 60em) {
|
||||
body:has(.nj-hero) .md-typeset .grid.cards {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
/* lists: Material's indent, bullets as small blue squares, numbers in the secondary text colour */
|
||||
.md-typeset ul:not(.task-list, .md-annotation-list) > li {
|
||||
position: relative;
|
||||
list-style: none;
|
||||
}
|
||||
.md-typeset ul:not(.task-list, .md-annotation-list) > li::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: .65em; /* middle of the first line at line-height 1.65 */
|
||||
left: -.95em;
|
||||
width: .36em;
|
||||
height: .36em;
|
||||
background-color: var(--nj-blue);
|
||||
}
|
||||
.md-typeset ol > li::marker {
|
||||
color: var(--md-default-fg-color--light);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.md-typeset .grid.cards > ul > li::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* wider page: Material's grid stops at 61rem (1220 px) */
|
||||
.md-grid {
|
||||
max-width: 72rem; /* 1440 px */
|
||||
}
|
||||
|
||||
/* tables: full width, 1 px line border with 6 px corners, header row on the panel colour, 15 px text */
|
||||
.md-typeset__table {
|
||||
display: block; /* Material: inline-block, so tables only grow to their content */
|
||||
}
|
||||
.md-typeset table:not([class]) {
|
||||
display: table;
|
||||
width: 100%;
|
||||
border: 1px solid var(--md-default-fg-color--lightest);
|
||||
border-radius: 6px;
|
||||
font-size: .75rem;
|
||||
line-height: 1.55;
|
||||
}
|
||||
.md-typeset table:not([class]) th {
|
||||
padding: .65em 1em;
|
||||
border-bottom: 1px solid var(--md-default-fg-color--lightest);
|
||||
background-color: var(--md-code-bg-color);
|
||||
color: var(--md-typeset-color);
|
||||
font-weight: 600;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
.md-typeset table:not([class]) th:first-child { border-top-left-radius: 5px; }
|
||||
.md-typeset table:not([class]) th:last-child { border-top-right-radius: 5px; }
|
||||
.md-typeset table:not([class]) td {
|
||||
padding: .65em 1em;
|
||||
border-top: 1px solid var(--md-default-fg-color--lightest);
|
||||
}
|
||||
.md-typeset table:not([class]) tbody tr:first-child td {
|
||||
border-top: 0;
|
||||
}
|
||||
.md-typeset table:not([class]) tbody tr:hover {
|
||||
background-color: var(--nj-blue-soft);
|
||||
box-shadow: none;
|
||||
}
|
||||
.md-typeset table:not([class]) td code {
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* numbers and header code stay on one line; a table wider than the screen scrolls sideways instead */
|
||||
.md-typeset table:not([class]) :is(td, th):is([align="right"], [style*="right"]),
|
||||
.md-typeset table:not([class]) th code {
|
||||
white-space: nowrap;
|
||||
}
|
||||
@media screen and (max-width: 44.984375em) {
|
||||
.md-typeset table:not([class]) {
|
||||
font-size: .7rem;
|
||||
}
|
||||
.md-typeset table:not([class]) :is(th, td) {
|
||||
padding: .55em .75em;
|
||||
}
|
||||
}
|
||||
|
||||
/* more room before headings (Material: h2 1.6em, h3 1.6em, h4-h6 1-1.25em) and at the end of each page (1.2rem) */
|
||||
.md-typeset h2 { margin-top: 2.4em; }
|
||||
.md-typeset h3 { margin-top: 2.2em; }
|
||||
.md-typeset h2 + h3 { margin-top: .8em; }
|
||||
.md-typeset :is(h4, h5, h6) { margin-top: 1.8em; }
|
||||
.md-content__inner {
|
||||
margin-bottom: 4.8rem; /* 96 px */
|
||||
}
|
||||
|
||||
/* Mermaid diagrams: white boxes with a blue outline, grey lines, Inter; shapes and spacing in js/mermaid-brand.js */
|
||||
:root > * {
|
||||
--md-mermaid-font-family: var(--md-text-font-family), sans-serif;
|
||||
--md-mermaid-edge-color: var(--md-default-fg-color--lighter);
|
||||
--md-mermaid-node-bg-color: var(--md-default-bg-color);
|
||||
--md-mermaid-node-fg-color: var(--nj-blue);
|
||||
--md-mermaid-label-bg-color: var(--md-default-bg-color);
|
||||
--md-mermaid-label-fg-color: var(--md-default-fg-color);
|
||||
--md-mermaid-sequence-actor-bg-color: var(--nj-blue-soft);
|
||||
--md-mermaid-sequence-actor-line-color: var(--md-default-fg-color--lighter);
|
||||
--md-mermaid-sequence-note-bg-color: var(--md-code-bg-color);
|
||||
--md-mermaid-sequence-note-border-color: var(--md-default-fg-color--lightest);
|
||||
--md-mermaid-sequence-number-fg-color: #fff;
|
||||
}
|
||||
|
||||
/* a diagram wider than the column scrolls sideways (js/mermaid-brand.js stops shrinking it at 80 %) */
|
||||
.md-typeset .mermaid {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
|
||||
/* ---- polish pass ---- */
|
||||
|
||||
/* header: a search field that reads as a field on the band, tabs with an active marker, readable GitHub facts */
|
||||
.md-header .md-search__form {
|
||||
border: 1px solid rgba(255, 255, 255, .22);
|
||||
border-radius: 6px;
|
||||
background-color: rgba(255, 255, 255, .12);
|
||||
transition: background-color 150ms, border-color 150ms;
|
||||
}
|
||||
.md-header .md-search__form:hover {
|
||||
border-color: rgba(255, 255, 255, .4);
|
||||
background-color: rgba(255, 255, 255, .2);
|
||||
}
|
||||
.md-search__output {
|
||||
border-radius: 0 0 6px 6px;
|
||||
box-shadow: 0 16px 40px rgba(5, 18, 48, .28);
|
||||
}
|
||||
.md-search-result__link:focus-visible, .md-search-result__more summary:focus-visible {
|
||||
outline: 2px solid var(--nj-blue);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
.md-tabs__link {
|
||||
font-size: .72rem;
|
||||
font-weight: 500;
|
||||
opacity: .85;
|
||||
}
|
||||
.md-tabs__item--active .md-tabs__link, .md-tabs__link:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
.md-tabs__item--active {
|
||||
box-shadow: inset 0 -2px 0 #fff;
|
||||
}
|
||||
.md-source__facts {
|
||||
font-size: .62rem;
|
||||
}
|
||||
|
||||
/* footer: deep brand blue instead of neutral black (the dark scheme keeps its own near-black) */
|
||||
[data-md-color-scheme="default"] {
|
||||
--md-footer-bg-color: #0d2a66;
|
||||
--md-footer-bg-color--dark: #0a2152;
|
||||
}
|
||||
.md-footer-meta .md-copyright, .md-footer-meta .md-copyright a {
|
||||
color: rgba(255, 255, 255, .72);
|
||||
}
|
||||
.md-footer__link {
|
||||
border-radius: 6px;
|
||||
transition: background-color 150ms;
|
||||
}
|
||||
.md-footer__link:is(:hover, :focus-visible) {
|
||||
background-color: rgba(255, 255, 255, .08);
|
||||
}
|
||||
|
||||
/* page title: tighter to the first paragraph; page actions (view/edit source) stay in the background */
|
||||
.md-typeset h1 {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.md-content__button {
|
||||
opacity: .55;
|
||||
transition: opacity 150ms;
|
||||
}
|
||||
.md-content__button:is(:hover, :focus-visible) {
|
||||
opacity: 1;
|
||||
}
|
||||
body:has(.nj-hero) .md-content__button {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* sidebars: bold marker for the current page, rail and marker for the table of contents */
|
||||
.md-nav__link--active {
|
||||
font-weight: 600;
|
||||
}
|
||||
.md-nav--secondary > .md-nav__list {
|
||||
margin-left: -.1rem;
|
||||
border-left: 1px solid color-mix(in srgb, var(--md-default-fg-color) 16%, transparent);
|
||||
}
|
||||
.md-nav--secondary .md-nav__link {
|
||||
margin-left: -1px;
|
||||
padding-left: .6rem;
|
||||
border-left: 2px solid transparent;
|
||||
}
|
||||
.md-nav--secondary .md-nav__link--active {
|
||||
border-left-color: var(--nj-blue);
|
||||
color: var(--nj-blue);
|
||||
}
|
||||
.md-nav--secondary .md-nav__list .md-nav__list {
|
||||
padding-left: .6rem;
|
||||
}
|
||||
.md-nav--secondary .md-nav__title {
|
||||
font-size: .64rem;
|
||||
letter-spacing: .04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* keyboard focus: one visible ring in the brand blue */
|
||||
.md-typeset a:focus-visible, .md-typeset .md-button:focus-visible, .md-typeset summary:focus-visible,
|
||||
.md-nav__link:focus-visible, .md-tabs__link:focus-visible, .md-top:focus-visible {
|
||||
outline: 2px solid var(--nj-blue);
|
||||
outline-offset: 2px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
.md-header :is(a, button, label):focus-visible, .nj-hero a:focus-visible {
|
||||
outline: 2px solid #fff;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* inline code must not stretch the line box (JetBrains Mono has tall metrics), abbreviations stay quiet */
|
||||
.md-typeset :not(pre) > code {
|
||||
line-height: 1;
|
||||
}
|
||||
.md-typeset abbr {
|
||||
border-bottom-color: var(--md-default-fg-color--lighter);
|
||||
}
|
||||
.md-typeset :is(h1, h2, h3, h4, a, .grid.cards > ul > li > p:first-child) abbr {
|
||||
border-bottom-color: transparent;
|
||||
}
|
||||
|
||||
/* number railroad diagram: inline SVG (docs/images/json_syntax_number.svg), follows the colour scheme */
|
||||
.md-typeset .railroad-wrap, .md-typeset .nj-fig-wrap {
|
||||
overflow-x: auto;
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
.md-typeset svg.railroad {
|
||||
display: block;
|
||||
width: 100%;
|
||||
min-width: 36rem;
|
||||
max-width: 52rem;
|
||||
margin-inline: auto;
|
||||
color: var(--md-default-fg-color);
|
||||
font-family: var(--md-text-font-family), sans-serif;
|
||||
}
|
||||
.railroad .rr-t { fill: color-mix(in srgb, var(--md-typeset-a-color) 10%, transparent); stroke: var(--md-typeset-a-color); stroke-width: 2; }
|
||||
.railroad .rr-track, .railroad .rr-n { stroke: color-mix(in srgb, currentColor 60%, var(--md-default-bg-color)); stroke-opacity: 1; } /* opaque, so overlapping segments do not darken */
|
||||
.railroad .rr-n { fill: color-mix(in srgb, currentColor 6%, transparent); stroke-width: 2; }
|
||||
.railroad .rr-bg { fill: var(--md-default-bg-color); }
|
||||
.railroad .rr-arrow { fill: currentColor; fill-opacity: .6; }
|
||||
.railroad text { fill: currentColor; text-anchor: middle; }
|
||||
.railroad .rr-c { font-family: var(--md-code-font-family), monospace; font-size: 16px; font-weight: 500; }
|
||||
.railroad .rr-b { font-size: 14.5px; font-weight: 500; }
|
||||
.railroad .rr-l { font-size: 14px; text-anchor: start; fill-opacity: .6; }
|
||||
.railroad .rr-name { font-size: 17px; font-weight: 700; fill-opacity: 1; }
|
||||
/* figures drawn as inline SVG (docs/images/callback_events.svg, range-*.svg): they follow the colour scheme */
|
||||
.md-typeset svg.nj-fig {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin-inline: auto;
|
||||
color: var(--md-default-fg-color);
|
||||
font-family: var(--md-text-font-family), sans-serif;
|
||||
}
|
||||
.md-typeset svg.nj-fig--range { min-width: 30rem; max-width: 40rem; }
|
||||
.md-typeset svg.nj-fig--cb { max-width: 30rem; }
|
||||
.nj-fig { --fg-line: color-mix(in srgb, currentColor 55%, var(--md-default-bg-color)); }
|
||||
.nj-fig .fg-cell { fill: color-mix(in srgb, var(--md-typeset-a-color) 14%, var(--md-default-bg-color)); stroke: var(--fg-line); stroke-width: 1.5; }
|
||||
.nj-fig .fg-cell--end { fill: none; stroke-dasharray: 4 3; }
|
||||
.nj-fig .fg-pill { fill: color-mix(in srgb, var(--md-typeset-a-color) 10%, var(--md-default-bg-color)); stroke: var(--md-typeset-a-color); stroke-width: 1.5; }
|
||||
.nj-fig .fg-pilltext { fill: var(--md-typeset-a-color); font-family: var(--md-code-font-family), monospace; font-size: 14px; font-weight: 500; text-anchor: middle; }
|
||||
.nj-fig .fg-arrow { stroke: var(--fg-line); stroke-width: 1.5; fill: none; }
|
||||
.nj-fig .fg-arrow--dash { stroke-dasharray: 3 3; }
|
||||
.nj-fig .fg-head { fill: var(--fg-line); }
|
||||
.nj-fig .fg-note { fill: currentColor; fill-opacity: .7; font-size: 13.5px; text-anchor: middle; }
|
||||
.nj-fig .fg-note--r { text-anchor: end; }
|
||||
.nj-fig .fg-note--l { text-anchor: start; }
|
||||
.nj-fig .fg-h { fill: currentColor; fill-opacity: .7; font-size: 15px; font-weight: 600; }
|
||||
.nj-fig .fg-code { fill: currentColor; font-family: var(--md-code-font-family), monospace; font-size: 16px; white-space: pre; }
|
||||
.nj-fig .fg-leg { font-size: 15px; }
|
||||
.nj-fig { --cb-os: #4eb05a; --cb-oe: #1a6b34; --cb-k: #e5534b; --cb-as: #f0c000; --cb-ae: #b07d00; --cb-v: #1f6fd1; }
|
||||
[data-md-color-scheme="slate"] .nj-fig { --cb-os: #7ee787; --cb-oe: #2ea043; --cb-k: #ff7b72; --cb-as: #f2cc60; --cb-ae: #c69026; --cb-v: #58a6ff; }
|
||||
.nj-fig .cb-os { fill: var(--cb-os); }
|
||||
.nj-fig .cb-oe { fill: var(--cb-oe); }
|
||||
.nj-fig .cb-k { fill: var(--cb-k); }
|
||||
.nj-fig .cb-as { fill: var(--cb-as); }
|
||||
.nj-fig .cb-ae { fill: var(--cb-ae); }
|
||||
.nj-fig .cb-v { fill: var(--cb-v); }
|
||||
.md-typeset img[src*="json-light"], .md-typeset img[src*="json-dark"] {
|
||||
border-radius: 8px;
|
||||
}
|
||||
.md-typeset img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* home page: content uses the same column as every other page */
|
||||
body:has(.nj-hero) .md-content {
|
||||
max-width: none;
|
||||
margin: 0;
|
||||
}
|
||||
.md-typeset .grid.cards {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/* 404 page (overrides/404.html) */
|
||||
.nj-404 {
|
||||
max-width: 30rem;
|
||||
padding: 2rem 0 3rem;
|
||||
}
|
||||
.nj-404__code {
|
||||
margin: 0 0 .4rem;
|
||||
color: var(--nj-blue);
|
||||
font-family: var(--md-code-font-family);
|
||||
font-size: .8rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
.md-typeset .nj-404 h1 {
|
||||
margin-bottom: .8rem;
|
||||
}
|
||||
.nj-404 .md-button {
|
||||
margin: .4rem .4rem 0 0;
|
||||
}
|
||||
|
||||
/* touch targets and phones */
|
||||
@media screen and (max-width: 59.984375em) {
|
||||
.md-nav__link {
|
||||
padding-block: .2rem;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 29.984375em) {
|
||||
.md-typeset h1 {
|
||||
font-size: 1.7em;
|
||||
}
|
||||
.md-typeset .highlight pre > code {
|
||||
font-size: .68rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* figure captions: "Figure N." in bold, close to the figure, set in from the text column; figures and tables are
|
||||
numbered per page, each with its own counter */
|
||||
.md-content__inner { counter-reset: nj-figure nj-table; }
|
||||
.md-typeset :is(.nj-caption, .nj-charts-caption) {
|
||||
max-width: none;
|
||||
margin: .3rem 2rem 1.5rem;
|
||||
font-size: .75rem;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
color: var(--md-default-fg-color--light);
|
||||
}
|
||||
.md-typeset :is(.nj-fig-wrap, .railroad-wrap, .nj-charts-grid-wrap) + :is(.nj-caption, .nj-charts-caption) { margin-top: -1.1rem; }
|
||||
.md-typeset .nj-charts-grid-wrap + :is(.nj-caption, .nj-charts-caption) { margin-top: .3rem; }
|
||||
.md-typeset :is(.nj-caption, .nj-charts-caption)::before {
|
||||
counter-increment: nj-figure;
|
||||
content: "Figure " counter(nj-figure) ". ";
|
||||
font-weight: 700;
|
||||
color: var(--md-default-fg-color);
|
||||
}
|
||||
@media screen and (max-width: 44.9375em) {
|
||||
.md-typeset :is(.nj-caption, .nj-charts-caption) { margin-inline: 1rem; }
|
||||
}
|
||||
|
||||
/* table captions: "Table N." in bold, directly below the table, in the figure caption style */
|
||||
.md-typeset .nj-table-caption {
|
||||
max-width: none;
|
||||
margin: .3rem 2rem 1.5rem;
|
||||
font-size: .75rem;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
color: var(--md-default-fg-color--light);
|
||||
}
|
||||
.md-typeset :is(.md-typeset__scrollwrap, .md-typeset__table) + .nj-table-caption { margin-top: -.4rem; }
|
||||
.md-typeset .nj-table-caption::before {
|
||||
counter-increment: nj-table;
|
||||
content: "Table " counter(nj-table) ". ";
|
||||
font-weight: 700;
|
||||
color: var(--md-default-fg-color);
|
||||
}
|
||||
@media screen and (max-width: 44.9375em) {
|
||||
.md-typeset .nj-table-caption { margin-inline: 1rem; }
|
||||
}
|
||||
Loaded 100 of 691 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user