Compare commits

...
Author SHA1 Message Date
Niels Lohmann 95519dbbcb Detect a patch stored inside the patched value with JSON_DIAGNOSTICS
patch_inplace applied a copy only when the patch was the value itself. With JSON_DIAGNOSTICS the parent pointers make it cheap to also detect a patch nested inside the value, so that case is handled the same way. Without diagnostics it stays documented undefined behavior.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 17:18:36 +01:00
Niels Lohmann 359c889ed2 Fix JSON_DIAGNOSTICS test crash and clang-tidy hit in patch_inplace self-aliasing
The spare-capacity test reallocated non-empty elements through get_ref(), which leaves stale parent pointers under JSON_DIAGNOSTICS; reserve while the array is empty instead. Suppress performance-unnecessary-copy-initialization for the copy that is needed because *this is modified.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 14:36:57 +01:00
Niels Lohmann 16793d6884 Merge develop
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 14:34:36 +01:00
Niels Lohmann ebf5a176c4 Fix remaining red CI on develop: Infer null dereferences, clang-tidy redundant init (#5943) 2026-10-27 14:31:31 +01:00
Niels Lohmann a47170346a docs: new design for the documentation site (#5934)
* docs: new design for the documentation site

Apply the brand to the Material for MkDocs site: Inter and JetBrains Mono
served by the site (upright and real italic), brand colours, blue header band
with the syntax pattern, wordmark in the header, new home page (hero, cards,
animated feature tour), 404 page, polish for tabs, search, footer, focus
rings, tables and code blocks, and theme features (code copy, previous/next
footer, TOC follow, search suggestions).

Draw the number railroad diagram, the parser callback events and the iterator
illustrations as inline SVGs that follow the light and dark scheme. The
generator scripts are in docs/mkdocs/scripts/figures; the feature slideshow
(json-light.svg, json-dark.svg, replacing json.gif on the home page) is built
by docs/mkdocs/scripts/slideshow. Decision nodes in five flowcharts become
hexagons, which need far less room.

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

* docs: add figures, table captions and a macro chooser

- Figures with numbered captions: SAX stepper, json_view layout and edit
  stepper, exception map, JSON pointer and patch walkers, QA pipeline,
  scaling and binary size charts, roadmap lanes, release timeline,
  integration decision tree and namespace builder
- Table captions (nj-table-caption) on 9 pages
- Compile times: modules and PCH charts, filesystem section, re-measured
  Figure 1, links between features/modules.md and compile_times.md
- Interactive macro chooser for features/arbitrary_types.md
- Link check: exclude URLs that answer the plugin with 400/401/419 or are
  dead (customers.md)

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

* docs: macro chooser generates adl_serializer for non-default-constructible types

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

* docs: cross-link concept pages and API pages in See also sections

Add See also links in both directions between the concept pages (features,
home, integration) and the API pages, write API links in code font, give every
entry a comment after a dash, and show the callback event figure on the parser
callbacks page.

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

* docs: address review comments on the new design

- Home: add a "Latest release" button
- Sponsors: update the list and group it by tier
- Features: list all feature pages on the index page
- Releases: add highlights per release, link the 4.0 roadmap, add the first commit to the timeline
- Exceptions: prefix all example messages with the exception name
- API: no code font for format names in the See also links of the to_/from_ pages
- Merge Patch: show the document before, the patch, and the result
- Replace "--" with typographic dashes, mark external links with an icon, center Mermaid diagrams

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 07:41:42 +01:00
Niels Lohmann 9edff5292d Merge branch 'develop' into fix-self-aliasing-pointer-patch
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 07:29:17 +01:00
Niels Lohmann 2bb2feeef4 Fix the red CI on develop (json_view pointer tokens, bson, from_json tests, Infer, IWYU) (#5942)
* json_view: pointer tokens that cannot be array indices create objects

editable_document::set() chose an array for a null parent whenever the
token consisted of digits, so "01" threw parse_error.106 and the empty
token threw, while basic_json::operator[](json_pointer) has created an
object for such tokens since #5358. This broke
unit-json_view_edit_values on develop. Use the same RFC 6901 array index
test as basic_json.

Also re-indent the unflatten test that the astyle check flagged.

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

* Fix the other red jobs on develop

- unit-bson: initialize recorder::events in its declaration (-Weffc++)
- unit-json_view_from_json: suppress -Wexit-time-destructors for the
  serialize-enum tables and -Wfloat-equal for same()
- unit-pointer_access: @infer-ignore NULLPTR_DEREFERENCE for the
  dereferences after get_ptr() that Infer reports
- json_view.hpp: IWYU no_include for the detail headers that the view
  code uses through nlohmann/json.hpp

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

* Fix GCC warnings in the json_view from_json test

GCC (-Weffc++, -Wfloat-equal) rejected unit-json_view_from_json.cpp
(ci_test_standards_gcc (20)): initialize the members of shape and
with_names, and suppress -Wfloat-equal for GCC like for clang.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 07:27:34 +01:00
Niels Lohmann 21ec9bd801 json_view: fewer allocations when parsing small documents (#5915)
- Size the buffer of decoded strings on its first growth from the input (a
  quarter of it plus 16 bytes, at most 4 KiB) instead of 272 bytes, so that a
  document with escapes does not grow it twice, with a zero-filled copy each
  time.
- Allocate the node index of documents with an estimate of up to 1024 nodes
  (was 256) together with the header, which saves one allocation. When the
  estimate is too low (dense numbers), that block stays unused: at most 16 KiB
  instead of 4 KiB. shrink_to_fit() cannot release it separately; the
  documentation says so.

Fresh parse of a 2.5 KB minified tweet: 993 to 958 ns (-3.5 %), traverse and
select -3 %, with no row consistently slower (Apple M1 Max, 30 rounds, three
runs). Dense numeric documents parse about 9 % faster and keep up to 16 KiB
more memory.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-27 07:22:49 +01:00
Niels Lohmann 8dd8f5ce8e Merge origin/develop into fix-self-aliasing-pointer-patch
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 21:39:59 +01:00
Niels Lohmann 94fe31eb9b docs: writing generic code for json_view (#5924)
* docs: writing generic code for json_view

A "Writing generic code" section on the json_view page: why a function
taking json_view accepts no other view, the three signatures for
editable, read-only, or either kind of view (passed by value), why the
modes do not convert, is_json_view, and how a from_json() reads views
(constrained to json values and views; the macros and the library's
conversions do it already) with what differs then (duplicate keys,
JSON_DIAGNOSTICS paths).

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

* docs: name the documents the generic view function accepts

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

* docs: views of read-only documents convert to editable views

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 20:13:32 +01:00
Niels Lohmann 9e67bfa115 json_view: the library's std conversions read views directly (#5923)
* json_view: the library's std conversions read views directly

The library's from_json() overloads (containers, maps, std::array, C
arrays, pairs, tuples, optional, valarray, forward_list, enums, binary,
paths, and scalars) accept views: their traits use the view's
basic_json type, and the few accesses that differ (get_ptr) go through
small helpers. from_json() of a view now finds them; only the probe
still looks up by ADL only. get<T>() of a view thus converts these types
without materialize(), with the same values and exceptions; from an
object, a repeated key keeps the last value, as parse() does.

The view keeps its direct paths for vectors of the types it converts
directly (faster than from_json()) and for containers of views; its
other vector and map paths are replaced by from_json(). For basic_json,
std::valarray and std::forward_list are read in one pass (40 % and 3.5 %
fewer instructions); all other conversions are unchanged.

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

* json_view: enable_if_not_view_t instead of '!' in the from_json() templates

astyle spaces out the template argument list when it contains a negation;
the alias spells the condition with negation<> and leaves the lines alone.

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

* json_view: compact the template parameter lists astyle had spaced out

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 20:13:31 +01:00
Niels Lohmann e5fe4ebdd2 json_view: from_json() of the macros reads views directly (#5922)
get<T>() and get_to() of a view call T's from_json() with the view itself
when that from_json() accepts views but not an unrelated probe type, and
fall back to materialize() otherwise. The from_json() functions of the
NLOHMANN_DEFINE_TYPE_*, NLOHMANN_DEFINE_DERIVED_TYPE_* and
NLOHMANN_JSON_SERIALIZE_ENUM(_STRICT) macros accept basic_json values and
views; a derived type whose base reads only json reads the base part
through materialize(). The library's own from_json() overloads are not
called with views: from_json() of a view (and of the probe) only looks up
functions by ADL.

New public trait nlohmann::is_json_view<T>, and the member type
basic_json_type of basic_json_view. With duplicate keys, the members of
such a T are those the view's lookups find (the first ones).

bench_decode.cpp measures decoding into structs (4-6x faster than
materialize().get<T>() on twitter, citm_catalog, and synthetic records).

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 20:13:31 +01:00
Niels Lohmann 5a2819c940 json_view: one SIMD macro set with the library (#5921)
The view's vector code follows JSON_NO_SIMD, like the lexer and the float
writer, and skips the CPU check of SSSE3 when the code is compiled for
SSSE3 anyway (__SSSE3__), like the lexer. JSON_VIEW_NO_SIMD and
JSON_VIEW_USE_SSSE3 and their ABI tags _vns and _vssse3 are removed; they
were never released. JSON_NO_SIMD keeps its tag _ns.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 20:13:31 +01:00
Niels Lohmann 4cdfa6d0f4 json_view: no save() and load() on big-endian targets (#5920)
The image format is little-endian only. Instead of throwing
type_error.320 at runtime, save_image(), load_image() and the members
save() and load() do not exist on a big-endian target, so a call fails to
compile, like set() on a read-only document. type_error.320 remains for
saving a discarded document.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 20:13:30 +01:00
Niels Lohmann 731f1b5bfb json_view: view_mode enum instead of bool Editable, node_kind for node::kind (#5919)
* json_view: view_mode enum instead of bool Editable, node_kind for node::kind

basic_json_document and basic_json_view take a view_mode (read_only, the
default, or editable) instead of a bool: basic_json_document<json, true>
did not say what true means. The shortcut aliases are unchanged.

The kind of a node is a node_kind (the value_t values plus link, 10 as
before), which removes the static_cast<std::uint8_t>(value_t::...) of
every comparison. The node and image layouts are unchanged.

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

* json_view: node_kind in the node writers, spell out read_only, comment fixes

The builder and the edit functions take and store a node_kind instead of
casting a value_t; the numbering assertions and the comments now speak of
node_kind, and the link kind notes that it follows value_t::discarded.
The read-only aliases name view_mode::read_only like the editable ones.
view_mode.md says the mode is a compile-time property of the type.

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

* json_view: views of read-only documents convert to editable views

A read-only document has no edits, so a view of it reads correctly as a
view of an editable document before its first edit. The implicit
conversion lets a function taking a json_editable_view accept the views
of both modes. There is no conversion the other way: a read-only view of
an editable document would read wrong values after the next edit.

The mode comparisons in the cross-mode operator==/!= use an
is_other_mode trait, which astyle keeps compact.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 20:13:30 +01:00
Niels Lohmann 24078c862d docs: fix BON8 documentation gaps found in the format review (#5932)
* docs: fix BON8 documentation gaps found in the format review

Verified each claim with small C++ probes before writing it.

- index.md: BON8 serialization is also incomplete for invalid UTF-8.
- bon8.md: document duplicate keys (last wins), the error ids for
  malformed input incl. 0xF5..0xF7 + 0x80..0xBF, exact string
  termination wording, wide integers and discarded values in the
  unsupported list, and title two untitled admonitions.
- exceptions.md: to_bon8 in type_error.316, BON8 in parse_error.112
  (with example) and .113, wide integers in out_of_range.407.
- binary_values.md: bytes 0..39 take one byte in BON8.
- from_bon8.md: note on strict UTF-8 and duplicate keys.

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

* Address review of the BON8 documentation

Restore the correct statement that marker bytes cannot begin a UTF-8 character (0x80..0xBF occur in valid UTF-8 as continuation bytes), and reword two sentences.

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

* docs: drop the discarded-value remark from the BON8 page

Discarded values are not mentioned on the individual format pages.

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

* docs: do not list invalid UTF-8 strings as a BON8 serialization gap

JSON text must be valid UTF-8, and to_bon8 rejects ill-formed strings by design (type_error.316), as documented on the BON8 page. Restore the original cell and realign the table.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 18:25:46 +01:00
Niels Lohmann 60107eda3f Read BJData ND-arrays of float16, restrict ND-array char to 0..127, correct BJData docs (#5931)
* Read ND-arrays of half floats and enforce the char limit in ND-arrays

BJData N-dimensional arrays with element type 'h' (float16) failed to
read with a misleading parse_error.112, because the reader's dtype name
table lacked 'h'. It now maps to "half", the JData name. The writer still
does not pack "half"; such an object is written as a plain object and
reads back equal.

BJData limits 'C' (char) to 0..127 in Draft 2 and Draft 3, and the 1-D
reader enforces this, but ND-arrays with _ArrayType_ "char" wrote values
up to 255 as 'C' elements and read them back without a check. The writer
now only packs values in 0..127 (others fall back to a plain object that
round-trips), and the reader rejects 'C' elements above 127 with
parse_error.113 like the 1-D reader.

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

* docs: correct and complete the BJData documentation

Verify the BJData chapter against the library and the Draft 2/3/4
specifications and fix what did not match:

- bjdata.md: correct the list of unused markers (N, not Z), the ND-array
  example (3x2, not 2x3), the conditions under which an object is packed
  as an ND-array (exactly three keys, row vectors, float-only elements for
  single/double, char 0..127, byte only in Draft 3), the binary table row
  and notes (which flag/draft combinations write [$B), the "$" type
  restriction (Draft 3, Z is excluded too), the H marker in the
  deserialization table, and the claim of a complete deserialization
  mapping. Document the supported drafts, that Draft 4 (SoA containers,
  extension type E) and column-major ND-arrays are rejected, ND-arrays of
  half floats, duplicate object keys, and link the Draft 3 specifications
  instead of master.
- Add an API page for basic_json::bjdata_version_t with an example, and
  link it from the nav, the API index and to_bjdata.
- Update binary_formats/index.md and binary_values.md, which still claimed
  that BJData has no binary type, and fix a wrong byte comment there.
- Document parse_error.115 and the out_of_range.408 cases for from_bjdata,
  the precise other_error.502 condition for to_bjdata, and reword the note
  on truncated unsigned integers in exceptions.md (only ND-array elements
  were truncated before 3.13.0).

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

* Regenerate single_include and apply astyle

Result of make amalgamate (including make pretty) for the preceding changes.

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

* Address review of the BJData documentation

The $ type restriction exists since Draft 2 (Draft 3 added B), $ requires a count, ND char above 127 is rejected on read, and the new API page is listed in alphabetical order in the nav.

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

* docs: format tables, use the Oxford comma

Reformat the tables changed by this PR (BJData serialization and
deserialization mappings, completeness and binary-value tables) so all
rows are aligned, and add the Oxford comma to lists of three or more
items in the added text.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 18:25:46 +01:00
Niels Lohmann dc768a7d5d Fix BSON binary subtype 0x02 and check the declared document size earlier (#5930)
* Write and read the inner length of BSON binary subtype 0x02

The BSON specification defines the payload of the "binary (old)" subtype
0x02 as an int32 followed by that many bytes. to_bson wrote the plain
payload instead, so decoders such as pymongo and libbson-based readers
rejected the bytes, and from_bson returned the inner length as part of the
payload (documented as lenient behavior in gh-5333).

The writer now emits the outer length (payload + 4), the subtype, the inner
int32 holding the payload size, and the payload. The reader requires an
outer length of at least 4 and an inner length equal to the outer length
minus 4 (the cases the bson-corpus lists as decode errors), reports parse
error 112 otherwise, and returns only the payload. Both directions change
together so that the round trip keeps working.

The single-reservation fast path for scalar entries declines subtype 0x02
because it has no room for the inner length.

This is a deliberate exception to the opt-in rule for behavior changes:
the previous output was invalid BSON.

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

* Check the declared BSON document size before reading its content

The BSON reader compared a document's declared size with the number of bytes
read only when it reached the terminator. The declared size never bounded
the reads, so a SAX handler saw the keys and values of a document whose size
was too small before parse error 112 was reported.

The container frame now stores the position where the document ends
according to its declared size. open_bson_document rejects a size below 5
(size prefix plus terminator) and an embedded document that does not end
before the terminator of its enclosing document; the element loop rejects an
element whose type byte leaves no room for the name terminator and the
document terminator. The terminator check stays and still catches a declared
size that is too large. No input that was accepted before is rejected now;
documents with a wrong size are reported earlier, with fewer SAX events, a
different byte position and, in three cases, a different message. The error
id (parse_error.112) is unchanged and strict=false still does not skip the
check.

The tests that asserted the old messages and positions are updated, with the
outer sizes of two inputs corrected so that they still exercise the embedded
document. New tests cover the SAX events, a size below 5, and an embedded
document that fits exactly.

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

* Document BSON subtype 0x02, document size checks, and lenient reads

Describe the inner length of binary subtype 0x02 that to_bson now writes and
from_bson checks and removes. Add the document size checks (parse_error.112,
not affected by strict=false) to bson.md and from_bson.md, and extend the
list of lenient reads with the UUID and MD5 payload lengths (not checked),
duplicate keys (last value wins), embedded NUL bytes in strings, and the
ignored trailing bytes with strict=false. State that the members of an object
are written in iteration order.

Correct the statement that element names are never validated on read: they
are checked and sanitized like string values by the error handler. Add the
BSON message to the examples of out_of_range.415 and type_error.321, the
subtype limit of 255 to the binary values page, CBOR to the formats that use
byte_container_with_subtype, and fix a typo in the incomplete mapping box.

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

* Regenerate single_include and apply astyle

Result of make amalgamate (including make pretty) for the preceding changes.

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

* Address review of the BSON documentation

Describe exactly when a too small document size is detected and note that subtype 2 data written by earlier versions is not readable.

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

* docs: use the Oxford comma, drop discarded-value remarks

Add the serial comma in a list added by this PR and remove the BSON
example of type_error.321 (with the type_error.317 remark) so the docs do
not mention discarded values for BSON; restore the original singular
heading of that section. No tables were changed by this PR.

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

* Fix -Weffc++ in the BSON recorder test and a clang-tidy use-auto hit

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

* Fix clang-tidy readability-redundant-member-init in BSON test

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 18:25:46 +01:00
Niels Lohmann 0c3570d44a Validate the UBJSON/BJData container type marker for count 0; fix UBJSON docs (#5929)
* Validate the optimized-container type marker for count 0 in UBJSON and BJData

The '$' type marker of an optimized container was only checked when an
element was read, so containers with count 0 accepted any marker:
`[$x#i0`, `{$x#i0` and `[$E#i0` parsed as empty containers although a
non-empty container with the same marker is rejected and the UBJSON
specification requires a legal marker after '$'.

get_ubjson_size_type() now checks the marker right after '$' against the
allowed set (UBJSON: Z N T F i U I l L d D H C S [ {; BJData: B U i u I m
l M L h d D C, with the existing exclusion of T F Z N S H [ {) and reports
parse_error.112 "marker ... is not a permitted optimized array type".

Input that was accepted and is now rejected: an optimized container with
count 0 and an invalid '$' type marker. Valid input is unaffected. Two
existing tests that used an invalid marker incidentally ("[$#" and a
negative-count case) were adapted.

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

* Correct and complete the UBJSON documentation

Fix statements that disagree with the behavior (checked with probes):
- `Z` is null; the unused marker is `N`.
- `$` requires `#`; use_type with use_size=false throws other_error.502 only
  for non-empty arrays, objects and binary values.
- NaN and infinity are written as IEEE 754 float64 and read back unchanged;
  the UBJSON specification encodes infinity as null.
- `H` is documented (semantics, parse_error.115, out_of_range.406); the
  "complete mapping" claim is qualified.
- use_type "same type" means same marker.
- Long Z/T/F arrays lose only the `$` annotation; the `#` count and the
  element markers are kept.
- from_ubjson lists the 112, 113, 115, 406 and 408 causes that occur for
  UBJSON, without the BJData-only ND-array wording.
- Duplicate object keys keep the last value; the `$` type marker is
  validated even for count 0.
- Smaller fixes: float32 row, "map" -> "object", https link, exception 110
  strict case, to_ubjson history of discarded values.

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

* Regenerate single_include and apply astyle

Result of make amalgamate (including make pretty) for the preceding changes.

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

* Address review of the UBJSON documentation

Clarify that empty containers carry no $ annotation of their own and note that a counted N object is not supported.

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

* docs: format tables, use the Oxford comma, drop discarded-value remarks

Reformat the two UBJSON mapping tables that this PR changed (uniform column
widths, padded cells), use the serial comma in lists of three or more in the
added text, and restore the original type_error.321 bullet in to_ubjson.md.

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

* Fix narrowing of the optimized-container count in BJData and UBJSON tests

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 18:25:45 +01:00
Niels Lohmann 2bbe80c043 Document MessagePack ext types and fix related doc errors (#5928)
* Document MessagePack ext types and fix related doc errors

Add an "Extension types (ext, fixext)" section to the MessagePack page:
ext/fixext are read as binary, the signed ext type is exposed as an
unsigned subtype 0..255 (-1 reads as 255), Timestamp is not interpreted,
subtypes are always written as ext/fixext, and subtypes above 255 throw
out_of_range.415. Add the 0xC1 row to the deserialization table, note
that duplicate keys keep the last value, and correct the NaN/Infinity
explanation, the "31 bytes / 15 elements" wording, the ill-formed UTF-8
sentence, and the generic 0xC1-key error message.

Add fixext16 and the unsigned subtype mapping to binary_t.md and
binary_values.md, reword "maximum of the MessagePack ext type" in
to_msgpack.md and exceptions.md, and mark MessagePack deserialization
as incomplete (non-string keys) in the binary formats overview.

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

* Address review of the MessagePack documentation

Name parse_error.113 for a 0xC1 map key, move the duplicate-key sentence out of the ext section, and keep the 0xC1 row in marker order.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 18:25:44 +01:00
Niels Lohmann d5da84249f Skip CBOR tags in front of map keys, validate indefinite text chunks, fix CBOR docs (#5927)
* Skip CBOR tags in front of map keys and validate indefinite text chunks

A tag in front of a text string map key was rejected with parse_error.113
even with cbor_tag_handler_t::ignore or store, although tags in front of
values are handled. The tags are now skipped iteratively before the key is
read; the handler error still rejects them.

The chunks of an indefinite-length text string were concatenated before
the single UTF-8 check, so a code point split over two chunks, or an
invalid chunk, was accepted. RFC 8949, Section 3.2.3 requires every chunk
to be valid on its own. With error_handler_t::strict, replace and ignore
each chunk is now checked; keep is unchanged. The chunks are appended with
append(ptr, len), so StringType needs nothing new.

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

* docs: correct and extend the CBOR documentation

Fix the negative-integer rows (they used MessagePack boundaries), the
number_integer range of the 0x1B row, and the half-precision entry in the
list of unused types; correct the NaN history (0xF9 since 3.8.0) and the
tagged-item wording (only the tag directly in front of a byte string is
stored, and only in the 0xD8..0xDB form). Document that to_cbor is not
RFC 8949 deterministic, that duplicate keys are accepted (last wins),
tags in front of keys, per-chunk UTF-8 validation, the exceptions
parse_error.113, out_of_range.406/408 of from_cbor, the pointer and
C array input traps, the partially written output on exceptions, and the
store/ignore results in the binary values example. Drop the claim that
the CBOR reader needs StringType::append(const StringType&) and
BinaryType::insert(pos, first, last).

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

* Regenerate single_include and apply astyle

Result of make amalgamate (including make pretty) for the preceding changes.

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

* Address review of the CBOR changes

Cite RFC 8949 Section 5.3.1 for duplicate keys, describe the out_of_range.408 condition precisely, rewrap a long line, and update the stale get_string comment (per-chunk UTF-8 check). single_include regenerated.

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

* docs: drop discarded-value remarks

Remove the mention that a discarded value cannot be serialized to CBOR
(type_error.321) from the exception-safety and mapping sections. The
integer table and all added prose already follow the table-format and
Oxford-comma rules.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 18:25:44 +01:00
Niels Lohmann 81d66291c5 Create objects for pointer tokens that cannot be array indices (#5358)
* create objects for tokens that cannot be array indices (#5357)

When operator[](json_pointer) traverses a level that does not exist yet,
the null value is turned into an array or an object depending on the
reference token. The check only tested whether all characters are digits,
so tokens that can never be a valid array index selected an array and
then failed:

- "01" (and any other token with a leading '0') threw parse_error.106
- the empty token threw out_of_range.404

Both tokens are valid object keys, and both work when the level already
exists as an object, so creating the level changed the outcome. Test the
token against the RFC 6901, Sect. 4 grammar for array indices instead, so
that such tokens create an object. This only affects pointers that threw
before.

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

* Clarify that the token 0 is a valid array index in operator[] docs

The note described valid array indices as "a nonempty sequence of digits
without a leading 0", which read literally excludes the token "0" itself,
contradicting both the code and the /foo/0/0/0 example in the next
sentence. Spell out the RFC 6901 grammar instead.

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

---------

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 17:13:48 +01:00
Niels LohmannandClaude Sonnet 5.5 c712df0637 docs: make the diff() and patch() documentation accurate; add tests (#5939)
* Throw out_of_range.411 for JSON Patch add into a null parent (#5917)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MKJf48vnGtTE25KscmjfaW
Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>

* docs: make the diff() and patch() documentation accurate; add tests

Document the exceptions to the diff round-trip invariant (NaN, discarded
values, number types), the path parameter, non-minimal patches, array and
object operation order, the ordered_json fallback, binary values in
serialized patches, the real complexity, duplicate member names in
operations, test on missing paths, and the exact out_of_range.403 message.
Add tests for these behaviors.

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

---------

Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 17:12:05 +01:00
Niels Lohmann 7a10bf25d2 docs: state merge_patch complexity and RFC 7396 limitations; test non-object, discarded, binary cases (#5938)
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 17:11:55 +01:00
Niels Lohmann c20b6eddf4 docs: correct JSON Pointer documentation and add tests (#5937)
Fix inaccurate or missing statements about unflatten (third round-trip
failure, empty token, typo), value (type_error.306 before pointer lookup),
contains (pointer overload), parent_pointer and operator<< (bad_alloc),
out_of_range.410 example, template parameter requirements (resize(n)), and
document the URI fragment form and non-unique member names of RFC 6901.
Add tests for the unflatten and value() cases.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 17:11:46 +01:00
Niels Lohmann 8679c011db Use flawfinder --exclude instead of listing directories (#5935)
Flawfinder 2.0.20 has an --exclude PATTERN option. Scan `./` and exclude
`*/single_include/*` so that new top-level directories are covered
automatically. The scanned file set is identical to the explicit
directory list.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 17:11:36 +01:00
Niels LohmannandClaude Sonnet 5.5 d6431a9104 Throw out_of_range.411 for JSON Patch add into a null parent (#5917) (#5918)
Claude-Session: https://claude.ai/code/session_01MKJf48vnGtTE25KscmjfaW

Signed-off-by: Niels Lohmann <niels.lohmann@gmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 17:11:25 +01:00
Niels Lohmann 0babaa1a4e Fix self-aliasing in json_pointer::operator/= and patch_inplace
json_pointer::operator/=(const json_pointer&) passed iterators into its
own token vector to insert() when a pointer was appended to itself
(p /= p), which is undefined behavior; libstdc++ produced "/a/b//" for
"/a/b". The pointer now appends a copy in that case.

basic_json::patch_inplace iterated the patch while changing *this, so
j.patch_inplace(j) read freed memory. It now applies a copy of the
patch when the patch is the value itself. A patch stored inside the
value remains undefined behavior and is documented as such; copying the
patch unconditionally would double the time of a large patch.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-26 12:10:55 +01:00
482 changed files with 16454 additions and 7912 deletions

No files matched your search

+3 -3
View File
@@ -163,9 +163,9 @@ jobs:
python3 $GENERATOR --list-tags python3 $GENERATOR --list-tags
TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l) TAG_COUNT=$(python3 $GENERATOR --list-tags | wc -l)
python3 $GENERATOR --abi-tags diag,_dp,_vns --abi-tags _diag --output $RUNNER_TEMP/abi_tags.natvis python3 $GENERATOR --abi-tags diag,_dp,_ns --abi-tags _diag --output $RUNNER_TEMP/abi_tags.natvis
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_vns -->' $RUNNER_TEMP/abi_tags.natvis grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_ns -->' $RUNNER_TEMP/abi_tags.natvis
grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_vns_v[0-9_]* -->' $RUNNER_TEMP/abi_tags.natvis grep -q '<!-- Namespace nlohmann::json_abi_diag_dp_ns_v[0-9_]* -->' $RUNNER_TEMP/abi_tags.natvis
test $(grep -c '<!-- Namespace ' $RUNNER_TEMP/abi_tags.natvis) -eq $(( $(grep -c '<!-- Namespace ' nlohmann_json.natvis) + 2 )) test $(grep -c '<!-- Namespace ' $RUNNER_TEMP/abi_tags.natvis) -eq $(( $(grep -c '<!-- Namespace ' nlohmann_json.natvis) + 2 ))
python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis python3 $GENERATOR --all --output $RUNNER_TEMP/all.natvis
+2 -2
View File
@@ -43,8 +43,8 @@ jobs:
- name: flawfinder_scan - name: flawfinder_scan
uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20 uses: david-a-wheeler/flawfinder@c4216b74cf2639ffa98503768bd6e4299b5440c9 # v2.0.20
with: with:
# single_include/ is omitted: it is generated from include/ and would report every finding twice # single_include/ is generated from include/ and would report every finding twice
arguments: '--sarif ./cmake ./docs ./include ./src ./tests ./tools' arguments: "--sarif --exclude '*/single_include/*' ./"
output: 'flawfinder_results.sarif' output: 'flawfinder_results.sarif'
- name: Upload analysis results to GitHub Security tab - name: Upload analysis results to GitHub Security tab
+1
View File
@@ -90,6 +90,7 @@ cc_library(
"include/nlohmann/detail/view/simd.hpp", "include/nlohmann/detail/view/simd.hpp",
"include/nlohmann/detail/view/string_ref.hpp", "include/nlohmann/detail/view/string_ref.hpp",
"include/nlohmann/detail/view/value.hpp", "include/nlohmann/detail/view/value.hpp",
"include/nlohmann/detail/view/view_mode.hpp",
"include/nlohmann/json.hpp", "include/nlohmann/json.hpp",
"include/nlohmann/json_fwd.hpp", "include/nlohmann/json_fwd.hpp",
"include/nlohmann/json_literals.hpp", "include/nlohmann/json_literals.hpp",
+1 -1
View File
@@ -309,7 +309,7 @@ The "Check amalgamation" workflow fails if the file is out of date.
The file covers the namespace variants with up to two ABI tags. A Natvis file for other configurations can be The file covers the namespace variants with up to two ABI tags. A Natvis file for other configurations can be
generated with the `--abi-tags` or `--all` options, for example generated with the `--abi-tags` or `--all` options, for example
`make natvis NATVIS_ARGS="--abi-tags _diag,_dp,_vns --output my_nlohmann_json.natvis"`; see `make natvis NATVIS_ARGS="--abi-tags _diag,_dp,_ns --output my_nlohmann_json.natvis"`; see
[`tools/generate_natvis`](tools/generate_natvis/README.md). With MSVC, CMake adds the file to the `nlohmann_json` [`tools/generate_natvis`](tools/generate_natvis/README.md). With MSVC, CMake adds the file to the `nlohmann_json`
target and installs it. target and installs it.
+1 -1
View File
@@ -120,7 +120,7 @@ $(AMALGAMATED_VIEW_FILE): $(SRCS)
tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_view.json -s . --verbose=yes tools/amalgamate/amalgamate.py -c tools/amalgamate/config_json_view.json -s . --verbose=yes
NATVIS_VENV=tools/generate_natvis/venv NATVIS_VENV=tools/generate_natvis/venv
# extra options for generate_natvis.py, e.g. NATVIS_ARGS="--abi-tags _diag,_dp,_vns --output my.natvis" # extra options for generate_natvis.py, e.g. NATVIS_ARGS="--abi-tags _diag,_dp,_ns --output my.natvis"
NATVIS_ARGS= NATVIS_ARGS=
# regenerate nlohmann_json.natvis from the ABI tags and version in include/nlohmann/detail/abi_macros.hpp # regenerate nlohmann_json.natvis from the ABI tags and version in include/nlohmann/detail/abi_macros.hpp
@@ -30,7 +30,7 @@ class (either explicitly or via the conversion operators).
## Return value ## Return value
1. (none) -- the converted value is written to the output parameter `val`. 1. (none) — the converted value is written to the output parameter `val`.
2. the JSON value `j` converted to `TargetType` 2. the JSON value `j` converted to `TargetType`
## Examples ## Examples
@@ -67,7 +67,9 @@ class (either explicitly or via the conversion operators).
## See also ## See also
- [to_json](to_json.md) - [`to_json`](to_json.md) - convert a C++ value to JSON
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - write your own `from_json` and `to_json` functions
- [Converting values](../../features/conversions.md) - overview of `get`, `get_to` and implicit conversions
## Version history ## Version history
+4 -4
View File
@@ -33,10 +33,10 @@ struct adl_serializer {
## See also ## See also
- [Arbitrary type conversions](../../features/arbitrary_types.md) - how to make your types convertible - [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 - [`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 - [`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 - [`NLOHMANN_DEFINE_TYPE_INTRUSIVE`](../macros/nlohmann_define_type_intrusive.md) - generate the conversion functions for a type
- [Specializing enum conversion](../../features/enum_conversion.md) - [Specializing enum conversion](../../features/enum_conversion.md) - serializing enums as JSON strings
## Version history ## Version history
@@ -36,7 +36,9 @@ This function is usually called by the constructors of the [basic_json](../basic
## See also ## See also
- [from_json](from_json.md) - [`from_json`](from_json.md) - convert JSON to a C++ value
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - write your own `from_json` and `to_json` functions
- [Converting values](../../features/conversions.md) - overview of `get`, `get_to` and implicit conversions
## Version history ## Version history
+8 -3
View File
@@ -148,15 +148,20 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
## See also ## See also
- [parse](parse.md) - deserialize from a compatible input - [`parse`](parse.md) - deserialize from a compatible input
- [sax_parse](sax_parse.md) - parse input using the SAX interface - [`sax_parse`](sax_parse.md) - parse input using the SAX interface
- [operator>>](../operator_gtgt.md) - deserialize from stream - [`operator>>`](../operator_gtgt.md) - deserialize from stream
- [`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) - opt in to rejecting a NUL byte in the input - [`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) - opt in to rejecting a NUL byte in the input
instead of treating it as end of input instead of treating it as end of input
- [`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md) - read a `std::istream` one character - [`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md) - read a `std::istream` one character
at a time at a time
- [`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) - read a `FILE*` with the locking stdio - [`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) - read a `FILE*` with the locking stdio
functions functions
- [Parsing](../../features/parsing/index.md) - overview of the parsing functions
- [Comments](../../features/comments.md) - ignore `//` and `/* */` comments while parsing
- [Trailing Commas](../../features/trailing_commas.md) - accept trailing commas in arrays and objects
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - handling parse errors and locating them in the input
- [Parsing Untrusted Input](../../features/parsing/untrusted_input.md) - limits and checks for input you do not control
## Version history ## Version history
+2 -2
View File
@@ -29,9 +29,9 @@ Linear in the size of `init`.
This function is only needed to express two edge cases that cannot be realized with the initializer list constructor This function is only needed to express two edge cases that cannot be realized with the initializer list constructor
([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are: ([`basic_json(initializer_list_t, bool, value_t)`](basic_json.md)). These cases are:
1. creating an array whose elements are all pairs whose first element is a string -- in this case, the initializer list 1. creating an array whose elements are all pairs whose first element is a string — in this case, the initializer list
constructor would create an object, taking the first elements as keys constructor would create an object, taking the first elements as keys
2. creating an empty array -- passing the empty initializer list to the initializer list constructor yields an empty 2. creating an empty array — passing the empty initializer list to the initializer list constructor yields an empty
object object
## Examples ## Examples
+6 -4
View File
@@ -69,10 +69,12 @@ Arrays are stored as pointers in a `basic_json` type. That is, for any access to
## See also ## See also
- [object_t](object_t.md) the type used to store JSON objects - [`object_t`](object_t.md) - the type used to store JSON objects
- [binary_t](binary_t.md) the type used to store binary values - [`binary_t`](binary_t.md) - the type used to store binary values
- [is_array](is_array.md) checks whether the JSON value is an array - [`is_array`](is_array.md) - checks whether the JSON value is an array
- [max_size](max_size.md) returns the maximum possible number of elements - [`max_size`](max_size.md) - returns the maximum possible number of elements
- [Types](../../features/types/index.md) - how arrays are stored
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ArrayType` template parameter
## Version history ## Version history
@@ -46,7 +46,8 @@ The function is equivalent to `static_cast<json_base_class_t&>(j)` (or `static_c
## See also ## See also
- [json_base_class_t](json_base_class_t.md) - type of the custom base class - [`json_base_class_t`](json_base_class_t.md) - type of the custom base class
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `CustomBaseClass` template parameter
## Version history ## Version history
+6 -4
View File
@@ -230,10 +230,12 @@ Strong exception safety: if an exception occurs, the original value stays intact
## See also ## See also
- documentation on [checked access](../../features/element_access/checked_access.md) - [Checked access](../../features/element_access/checked_access.md) - element access with range checking
- [`operator[]`](operator%5B%5D.md) for unchecked access by reference - [`operator[]`](operator%5B%5D.md) - unchecked access by reference
- [`value`](value.md) for access with default value - [`value`](value.md) - access with default value
- [basic_json_view::at](../basic_json_view/at.md) - the same access on a zero-copy view - [`basic_json_view::at`](../basic_json_view/at.md) - the same access on a zero-copy view
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
- [JSON Pointer](../../features/json_pointer.md) - access nested values with a pointer
## Version history ## Version history
+3 -2
View File
@@ -57,8 +57,9 @@ Constant.
## See also ## See also
- [front](front.md) to access the first element - [`front`](front.md) - to access the first element
- [basic_json_view::back](../basic_json_view/back.md) - the same access on a zero-copy view - [`basic_json_view::back`](../basic_json_view/back.md) - the same access on a zero-copy view
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
## Version history ## Version history
+14 -10
View File
@@ -52,7 +52,7 @@ basic_json(basic_json&& other) noexcept;
The postcondition of this constructor can be restored by calling [`clear()`](clear.md). The postcondition of this constructor can be restored by calling [`clear()`](clear.md).
2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`) 2. Create a `#!json null` JSON value. It either takes a null pointer as parameter (explicitly creating `#!json null`)
or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read -- it is only used to or no parameter (implicitly creating `#!json null`). The passed null pointer itself is not read — it is only used to
choose the right constructor. choose the right constructor.
3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method 3. This is a "catch all" constructor for all compatible JSON types; that is, types for which a `to_json()` method
@@ -113,19 +113,22 @@ basic_json(basic_json&& other) noexcept;
```mermaid ```mermaid
flowchart TD flowchart TD
A(["initializer_list init"]) --> B{"empty, or every element is a 2-element<br/>array whose first element is a string?"} 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 -->|"yes"| C{{"type_deduction"}}
B -->|"no"| D{"type_deduction"} B -->|"no"| D{{"type_deduction"}}
C -->|"true"| OBJ["create object"] C -->|"true"| OBJ["create object"]
C -->|"false"| E{"manual_type"} C -->|"false"| E{{"manual_type"}}
E -->|"object"| OBJ E -->|"object"| OBJ
E -->|"array"| ARR["create array"] E -->|"array"| ARR["create array"]
D -->|"true"| ARR D -->|"true"| ARR
D -->|"false"| F{"manual_type"} D -->|"false"| F{{"manual_type"}}
F -->|"array"| ARR F -->|"array"| ARR
F -->|"object"| ERR["throw type_error.301"] 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: 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. 1. The empty initializer list is written as `#!cpp {}` which is exactly an empty JSON object.
@@ -473,12 +476,13 @@ basic_json(basic_json&& other) noexcept;
## See also ## See also
- [array](array.md) create a JSON array value, forcing array creation from an initializer list even when it looks like - [`array`](array.md) - create a JSON array value, forcing array creation from an initializer list even when it looks like
an object an object
- [object](object.md) create a JSON object value, forcing object creation from an initializer list - [`object`](object.md) - create a JSON object value, forcing object creation from an initializer list
- [binary](binary.md) create a JSON binary array value - [`binary`](binary.md) - create a JSON binary array value
- [operator=](operator=.md) copy assignment operator - [`operator=`](operator=.md) - copy assignment operator
- [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values - [Creating JSON values](../../features/creating_values.md) - the article on creating JSON values
- [Converting values](../../features/conversions.md) - which C++ types can be converted
## Version history ## Version history
+11 -6
View File
@@ -7,7 +7,12 @@ const_iterator begin() const noexcept;
Returns an iterator to the first element. Returns an iterator to the first element.
![Illustration from cppreference.com](../../images/range-begin-end.svg) <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 ## Return value
@@ -39,12 +44,12 @@ Constant.
## See also ## See also
- [end](end.md) returns an iterator to one past the last element - [`end`](end.md) - returns an iterator to one past the last element
- [cbegin](cbegin.md) returns a const iterator to the first element - [`cbegin`](cbegin.md) - returns a const iterator to the first element
- [rbegin](rbegin.md) returns a reverse iterator to the last element - [`rbegin`](rbegin.md) - returns a reverse iterator to the last element
- [items](items.md) returns an iteration proxy to access keys and values during range-based for loops - [`items`](items.md) - returns an iteration proxy to access keys and values during range-based for loops
- [Iterators](../../features/iterators.md) - the article on iterators - [Iterators](../../features/iterators.md) - the article on iterators
- [basic_json_view::begin](../basic_json_view/begin.md) - the same iteration on a zero-copy view (in document order, - [`basic_json_view::begin`](../basic_json_view/begin.md) - the same iteration on a zero-copy view (in document order,
not sorted by key) not sorted by key)
## Version history ## Version history
+5 -4
View File
@@ -63,10 +63,11 @@ initialization of a binary array type, for backwards compatibility and so it doe
## See also ## See also
- [binary_t](binary_t.md) type for binary values - [Binary formats](../../features/binary_formats/index.md) - formats that can store binary values
- [get_binary](get_binary.md) get a reference to the stored binary value - [`binary_t`](binary_t.md) - type for binary values
- [is_binary](is_binary.md) return whether the value is binary - [`get_binary`](get_binary.md) - get a reference to the stored binary value
- [byte_container_with_subtype](../byte_container_with_subtype/index.md) container for binary values with subtype - [`is_binary`](is_binary.md) - return whether the value is binary
- [`byte_container_with_subtype`](../byte_container_with_subtype/index.md) - container for binary values with subtype
- [Binary Values](../../features/binary_values.md) - the article on binary values - [Binary Values](../../features/binary_values.md) - the article on binary values
## Version history ## Version history
+7 -4
View File
@@ -41,7 +41,7 @@ represent a byte array in modern C++.
[`byte_container_with_subtype`](../byte_container_with_subtype/index.md) derives directly from it. Its [`byte_container_with_subtype`](../byte_container_with_subtype/index.md) derives directly from it. Its
`value_type` must additionally be exactly one byte wide (e.g., `std::uint8_t`/`char`/`std::byte`): the binary `value_type` must additionally be exactly one byte wide (e.g., `std::uint8_t`/`char`/`std::byte`): the binary
serializers (CBOR, MessagePack, BSON, UBJSON) read and write the container's raw bytes via serializers (CBOR, MessagePack, BSON, UBJSON) read and write the container's raw bytes via
`reinterpret_cast`, which is only correct for byte-sized elements -- a container like `reinterpret_cast`, which is only correct for byte-sized elements — a container like
`#!cpp std::vector<std::intptr_t>` will not work as `BinaryType`. The elements must be stored contiguously, and `#!cpp std::vector<std::intptr_t>` will not work as `BinaryType`. The elements must be stored contiguously, and
the binary readers additionally require `resize()` and `operator[]`. See the binary readers additionally require `resize()` and `operator[]`. See
[Template Parameter Requirements](../../features/types/template_parameters.md#binarytype) for the full list. [Template Parameter Requirements](../../features/types/template_parameters.md#binarytype) for the full list.
@@ -90,8 +90,9 @@ type `#!cpp binary_t*` must be dereferenced.
- MessagePack - MessagePack
- If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1, - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, or 16 elements, the fixext family (fixext1,
fixext2, fixext4, fixext8) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The subtype is fixext2, fixext4, fixext8, fixext16) is used. For other sizes, the ext family (ext8, ext16, ext32) is used. The
then added as a signed 8-bit integer. subtype is then written as the signed 8-bit ext type: subtypes 128 to 255 map to the negative (reserved) ext
types, and on reading the ext type is exposed as an unsigned subtype from 0 to 255.
- If no subtype is given, the bin family (bin8, bin16, bin32) is used. - If no subtype is given, the bin family (bin8, bin16, bin32) is used.
- BSON - BSON
@@ -117,7 +118,9 @@ type `#!cpp binary_t*` must be dereferenced.
## See also ## See also
- [byte_container_with_subtype](../byte_container_with_subtype/index.md) - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [Binary formats](../../features/binary_formats/index.md) - formats that can store binary values
- [`byte_container_with_subtype`](../byte_container_with_subtype/index.md) - container type used by binary values
## Version history ## Version history
@@ -0,0 +1,48 @@
# <small>nlohmann::basic_json::</small>bjdata_version_t
```cpp
enum class bjdata_version_t
{
draft2,
draft3
};
```
This enumeration is used in [`to_bjdata`](to_bjdata.md) to choose the version of the BJData specification to write:
draft2
: BJData Draft 2 (the default). Binary values are written as arrays of `U` integers, and ND-arrays with
`"_ArrayType_": "byte"` are written as regular objects, since the `B` marker is not part of Draft 2.
draft3
: BJData Draft 3. Binary values are written as `B` elements: as an optimized binary array (`[$B#`) if both `use_size`
and `use_type` are set, and as an array of `B`-prefixed elements otherwise. ND-arrays with
`"_ArrayType_": "byte"` are written as packed arrays (`[$B#[...]`).
Only the writer is affected by the version. [`from_bjdata`](from_bjdata.md) reads the markers of both drafts.
## Examples
??? example
The example below shows how the different values of the `bjdata_version_t` influence the serialization of a binary
value with [`to_bjdata`](to_bjdata.md).
```cpp
--8<-- "examples/bjdata_version_t.cpp"
```
Output:
```json
--8<-- "examples/bjdata_version_t.output"
```
## See also
- [to_bjdata](to_bjdata.md) serializes a JSON value to BJData
- [BJData](../../features/binary_formats/bjdata.md) - the article on the BJData format
## Version history
- Added in version 3.12.0.
+3 -1
View File
@@ -47,7 +47,9 @@ Boolean values are stored directly inside a `basic_json` type.
## See also ## See also
- [is_boolean](is_boolean.md) checks whether the JSON value is a boolean - [`is_boolean`](is_boolean.md) - checks whether the JSON value is a boolean
- [Types](../../features/types/index.md) - how booleans are stored
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `BooleanType` template parameter
## Version history ## Version history
+10 -5
View File
@@ -6,7 +6,12 @@ const_iterator cbegin() const noexcept;
Returns an iterator to the first element. Returns an iterator to the first element.
![Illustration from cppreference.com](../../images/range-begin-end.svg) <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 ## Return value
@@ -38,11 +43,11 @@ Constant.
## See also ## See also
- [begin](begin.md) returns an iterator to the first element - [`begin`](begin.md) - returns an iterator to the first element
- [cend](cend.md) returns a const iterator to one past the last element - [`cend`](cend.md) - returns a const iterator to one past the last element
- [crbegin](crbegin.md) returns a const reverse iterator to the last element - [`crbegin`](crbegin.md) - returns a const reverse iterator to the last element
- [Iterators](../../features/iterators.md) - the article on iterators - [Iterators](../../features/iterators.md) - the article on iterators
- [basic_json_view::cbegin](../basic_json_view/cbegin.md) - the same iteration on a zero-copy view - [`basic_json_view::cbegin`](../basic_json_view/cbegin.md) - the same iteration on a zero-copy view
## Version history ## Version history
@@ -15,11 +15,13 @@ error
: report a parse error in case of a tag (the `from_cbor` overloads throw a `parse_error` exception by default) : report a parse error in case of a tag (the `from_cbor` overloads throw a `parse_error` exception by default)
ignore ignore
: ignore tags : ignore tags (also in front of a text string map key)
store store
: store tagged byte strings (for bytes 0xd8..0xdb) as binary values with the tag as subtype; other tagged values are : store tagged byte strings (for bytes 0xd8..0xdb) as binary values with the tag as subtype; other tagged values are
read as if the tag were ignored. If several tags precede a byte string, only the innermost one is stored. read as if the tag were ignored. If several tags precede a byte string, only the tag directly in front of it is
stored, and only when it has the form 0xd8..0xdb (a tag 0..23 written as 0xc0..0xd7 is skipped). Tags in front of a
text string map key are skipped.
## Examples ## Examples
@@ -40,8 +42,9 @@ store
## See also ## See also
- [from_cbor](from_cbor.md) deserializes a JSON value from CBOR - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [input_format_t](input_format_t.md) the enumeration of supported input formats - [`from_cbor`](from_cbor.md) - deserializes a JSON value from CBOR
- [`input_format_t`](input_format_t.md) - the enumeration of supported input formats
- [CBOR](../../features/binary_formats/cbor.md) - the article on the CBOR format - [CBOR](../../features/binary_formats/cbor.md) - the article on the CBOR format
## Version history ## Version history
+10 -5
View File
@@ -6,7 +6,12 @@ const_iterator cend() const noexcept;
Returns an iterator to one past the last element. Returns an iterator to one past the last element.
![Illustration from cppreference.com](../../images/range-begin-end.svg) <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 ## Return value
@@ -38,11 +43,11 @@ Constant.
## See also ## See also
- [end](end.md) returns an iterator to one past the last element - [`end`](end.md) - returns an iterator to one past the last element
- [cbegin](cbegin.md) returns a const iterator to the first element - [`cbegin`](cbegin.md) - returns a const iterator to the first element
- [crend](crend.md) returns a const reverse iterator to one before the first element - [`crend`](crend.md) - returns a const reverse iterator to one before the first element
- [Iterators](../../features/iterators.md) - the article on iterators - [Iterators](../../features/iterators.md) - the article on iterators
- [basic_json_view::cend](../basic_json_view/cend.md) - the same iteration on a zero-copy view - [`basic_json_view::cend`](../basic_json_view/cend.md) - the same iteration on a zero-copy view
## Version history ## Version history
+3 -2
View File
@@ -54,8 +54,9 @@ All iterators, pointers, and references related to this container are invalidate
## See also ## See also
- [erase](erase.md) removes elements from a JSON value - [`erase`](erase.md) - removes elements from a JSON value
- [empty](empty.md) checks whether the JSON value has no elements - [`empty`](empty.md) - checks whether the JSON value has no elements
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history ## Version history
+13 -5
View File
@@ -61,11 +61,18 @@ Strong exception safety: if an exception occurs, the original value stays intact
## Complexity ## Complexity
Logarithmic in the size of the JSON object. 1. Logarithmic in the size of the JSON object.
2. Logarithmic in the size of the JSON object.
3. At most one lookup per reference token of `ptr`, each logarithmic in the size of the container at that level:
O(*n* log *m*) for *n* reference tokens and containers of size at most *m*.
4. Deleted; a call with an integral argument does not compile.
## Notes ## Notes
- This method always returns `#!cpp false` when executed on a JSON type that is not an object. - Overloads (1) and (2) always return `#!cpp false` when executed on a JSON type that is not an object. Overload (3)
also works on arrays and on primitive values: the empty JSON pointer resolves in every JSON value (so
`#!cpp json(1).contains(""_json_pointer)` returns `#!cpp true`), and `#!cpp json({1, 2}).contains("/1"_json_pointer)`
returns `#!cpp true`.
- This method can be executed on any JSON value type. - This method can be executed on any JSON value type.
- Calling this function with an integer argument (for example, `#!cpp contains(0)`) does not compile: such an argument - Calling this function with an integer argument (for example, `#!cpp contains(0)`) does not compile: such an argument
would otherwise implicitly convert to a null `#!cpp const char*` and, from there, cause undefined behavior when would otherwise implicitly convert to a null `#!cpp const char*` and, from there, cause undefined behavior when
@@ -134,9 +141,10 @@ Logarithmic in the size of the JSON object.
## See also ## See also
- [find](find.md) find a value in an object - [`find`](find.md) - find a value in an object
- [count](count.md) returns the number of occurrences of a key - [`count`](count.md) - returns the number of occurrences of a key
- [basic_json_view::contains](../basic_json_view/contains.md) - the same check on a zero-copy view - [`basic_json_view::contains`](../basic_json_view/contains.md) - the same check on a zero-copy view
- [Element Access](../../features/element_access/index.md#does-this-key-exist) - how to test whether a key exists
## Version history ## Version history
+4 -3
View File
@@ -85,9 +85,10 @@ Logarithmic in the size of the JSON object.
## See also ## See also
- [find](find.md) find a value in an object - [`find`](find.md) - find a value in an object
- [contains](contains.md) checks whether a key exists - [`contains`](contains.md) - checks whether a key exists
- [basic_json_view::count](../basic_json_view/count.md) - the same check on a zero-copy view - [`basic_json_view::count`](../basic_json_view/count.md) - the same check on a zero-copy view
- [Element Access](../../features/element_access/index.md#does-this-key-exist) - how to test whether a key exists
## Version history ## Version history
+10 -4
View File
@@ -6,7 +6,13 @@ const_reverse_iterator crbegin() const noexcept;
Returns an iterator to the reverse-beginning; that is, the last element. Returns an iterator to the reverse-beginning; that is, the last element.
![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) <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 ## Return value
@@ -38,9 +44,9 @@ Constant.
## See also ## See also
- [crend](crend.md) returns a const reverse iterator to one before the first element - [`crend`](crend.md) - returns a const reverse iterator to one before the first element
- [rbegin](rbegin.md) returns a reverse iterator to the last element - [`rbegin`](rbegin.md) - returns a reverse iterator to the last element
- [cbegin](cbegin.md) returns a const iterator to the first element - [`cbegin`](cbegin.md) - returns a const iterator to the first element
- [Iterators](../../features/iterators.md) - the article on iterators - [Iterators](../../features/iterators.md) - the article on iterators
## Version history ## Version history
+10 -4
View File
@@ -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, 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. attempting to access it results in undefined behavior.
![Illustration from cppreference.com](../../images/range-rbegin-rend.svg) <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 ## Return value
@@ -39,9 +45,9 @@ Constant.
## See also ## See also
- [crbegin](crbegin.md) returns a const reverse iterator to the last element - [`crbegin`](crbegin.md) - returns a const reverse iterator to the last element
- [rend](rend.md) returns a reverse iterator to one before the first element - [`rend`](rend.md) - returns a reverse iterator to one before the first element
- [cend](cend.md) returns a const iterator to one past the last element - [`cend`](cend.md) - returns a const iterator to one past the last element
- [Iterators](../../features/iterators.md) - the article on iterators - [Iterators](../../features/iterators.md) - the article on iterators
## Version history ## Version history
@@ -32,8 +32,10 @@ The actual comparator used depends on [`object_t`](object_t.md) and can be obtai
## See also ## See also
- [object_comparator_t](object_comparator_t.md) the comparator actually used by `object_t` - [`object_comparator_t`](object_comparator_t.md) - the comparator actually used by `object_t`
- [object_t](object_t.md) the type used to store JSON objects - [`object_t`](object_t.md) - the type used to store JSON objects
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ObjectType` template parameter
- [Object order](../../features/object_order.md) - preserve the insertion order of keys
## Version history ## Version history
+47 -9
View File
@@ -2,17 +2,27 @@
```cpp ```cpp
static basic_json diff(const basic_json& source, static basic_json diff(const basic_json& source,
const basic_json& target); const basic_json& target,
const string_t& path = "");
``` ```
Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling Creates a [JSON Patch](http://jsonpatch.com) so that value `source` can be changed into the value `target` by calling
[`patch`](patch.md) function. [`patch`](patch.md) function.
For two JSON values `source` and `target`, the following code always yields `#!cpp true`: For two JSON values `source` and `target`, the following code yields `#!cpp true`:
```cpp ```cpp
source.patch(diff(source, target)) == target; source.patch(diff(source, target)) == target;
``` ```
The equality holds up to [`operator==`](operator_eq.md), so it has the following exceptions:
- A value that is not equal to itself cannot round-trip. This applies to `NaN` (also nested in an array or object) and
to [discarded](is_discarded.md) values: `diff` emits a `replace` operation for them. A `NaN` in the patch is
serialized as `#!json null`, so a patch that was dumped and parsed again would set `#!json null`.
- Numbers that compare equal produce no operation, even if their types or signs differ: `diff(1, 1.0)`,
`diff(1u, 1)` (unsigned and signed integer) and `diff(0.0, -0.0)` all return `#!json []`. The patched value is then
the `source` and keeps its number type.
## Parameters ## Parameters
`source` (in) `source` (in)
@@ -21,6 +31,12 @@ source.patch(diff(source, target)) == target;
`target` (in) `target` (in)
: JSON value to compare against : JSON value to compare against
`path` (in)
: a prefix that is put verbatim in front of the `path` member of every operation (default: `""`, which addresses the
root of the value). The prefix is neither escaped nor validated: `#!cpp diff(1, 2, "abc")` yields an operation with
the `path` `abc`, which is not a valid JSON Pointer. Use it with a valid JSON Pointer such as `/root` and escape
`~` and `/` in its reference tokens (see [JSON Pointer](../../features/json_pointer.md)).
## Return value ## Return value
a JSON patch to convert the `source` to `target` a JSON patch to convert the `source` to `target`
@@ -31,11 +47,32 @@ Strong guarantee: `source` and `target` are never modified.
## Complexity ## Complexity
Linear in the lengths of `source` and `target`. Linear in the total number of values (including nested ones) in `source` and `target`, times the cost of a key-based
object operation (looking up a key in an object): logarithmic for [`json`](../json.md), and linear for
[`ordered_json`](../ordered_json.md) (see [`ordered_map` complexity](../ordered_map.md#complexity)). For
`ordered_json`, diffing two objects with `n` and `m` members therefore takes O((n+m)²) when their keys do not line up
(e.g., a key was added or the keys are in a different order). The size of the patch is proportional to the number of
operations times the length of their paths, so a small change deep inside a value yields a long `path`.
## Notes ## Notes
Currently, only `remove`, `add`, and `replace` operations are generated. - Currently, only `remove`, `add`, and `replace` operations are generated.
- The patch is correct, but not guaranteed to be minimal. For instance, `diff([1,2,3], [0,1,2,3])` yields three
`replace` operations and one `add` operation instead of a single insertion.
- Differences between two arrays are reported index by index. Elements that were added at the end of the array are added
with `add` operations on the path `/-` (appended in order), and elements that were removed are removed with `remove`
operations from the highest index down to the lowest, so that the remaining indices stay valid.
- For objects, the operations for the members of `source` come first (`replace`, `remove`, or the operations for nested
values, in the iteration order of `source`), followed by `add` operations for the members that only `target` has.
- For [`ordered_json`](../ordered_json.md), objects with the same keys in a different order are different. As a patch
cannot reorder members, `diff` removes all keys of the `source` object and adds them again in the order of the
`target`.
- If `source` and `target` differ as a whole (e.g., different types), the patch consists of a single `replace`
operation for the root of the value, i.e., with the `path` `""` (or the given `path` prefix).
- The `value` members of the patch hold copies of values of `target`. A [binary](../../features/binary_values.md) value
has no JSON representation: when a patch that contains one is serialized, it becomes an object such as
`#!json {"bytes":[1,3],"subtype":null}`, so a parsed patch no longer holds a binary value (and would set that object
instead).
## Examples ## Examples
@@ -55,11 +92,12 @@ Currently, only `remove`, `add`, and `replace` operations are generated.
## See also ## See also
- [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - specification of JSON Patch
- [patch](patch.md) applies a JSON Patch - [`patch`](patch.md) - applies a JSON Patch
- [patch_inplace](patch_inplace.md) applies a JSON Patch in place - [`patch_inplace`](patch_inplace.md) - applies a JSON Patch in place
- [merge_patch](merge_patch.md) applies a JSON Merge Patch - [`merge_patch`](merge_patch.md) - applies a JSON Merge Patch
- [merge_diff](merge_diff.md) creates a diff as a JSON Merge Patch - [`merge_diff`](merge_diff.md) - creates a diff as a JSON Merge Patch
- [JSON Patch and Diff](../../features/json_patch.md) - the article on JSON Patch
## Version history ## Version history
+3 -3
View File
@@ -89,9 +89,9 @@ Binary values are serialized as an object containing two keys:
## See also ## See also
- [to_string](to_string.md) returns a string representation of a JSON value - [`to_string`](to_string.md) - returns a string representation of a JSON value
- [operator<<](../operator_ltlt.md) serialize to stream - [`operator<<`](../operator_ltlt.md) - serialize to stream
- [`basic_json_view::dump`](../basic_json_view/dump.md) the corresponding function of `basic_json_view`, serializing - [`basic_json_view::dump`](../basic_json_view/dump.md) - the corresponding function of `basic_json_view`, serializing
directly from a flat index without building a `basic_json` value directly from a flat index without building a `basic_json` value
- [Serialization](../../features/serialization.md) - the serialization article - [Serialization](../../features/serialization.md) - the serialization article
+2 -2
View File
@@ -63,8 +63,8 @@ Logarithmic in the size of the container, O(log(`size()`)).
## See also ## See also
- [emplace_back](emplace_back.md) add a value to an array - [`emplace_back`](emplace_back.md) - add a value to an array
- [insert](insert.md) add values to an array/object - [`insert`](insert.md) - add values to an array/object
- [Modifying values](../../features/modifying_values.md) - the article on modifying values - [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history ## Version history
@@ -61,8 +61,8 @@ Amortized constant.
## See also ## See also
- [operator+=](operator+=.md) add a value to an array/object - [`operator+=`](operator+=.md) - add a value to an array/object
- [push_back](push_back.md) add a value to an array/object - [`push_back`](push_back.md) - add a value to an array/object
- [Modifying values](../../features/modifying_values.md) - the article on modifying values - [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history ## Version history
+4 -4
View File
@@ -41,7 +41,7 @@ bool empty() const noexcept
## Notes ## Notes
This function does not return whether a string stored as JSON value is empty -- it returns whether the JSON container This function does not return whether a string stored as JSON value is empty — it returns whether the JSON container
itself is empty which is `#!cpp false` in the case of a string. itself is empty which is `#!cpp false` in the case of a string.
## Examples ## Examples
@@ -62,9 +62,9 @@ itself is empty which is `#!cpp false` in the case of a string.
## See also ## See also
- [size](size.md) returns the number of elements - [`size`](size.md) - returns the number of elements
- [clear](clear.md) clears the content and resets the value to the default value - [`clear`](clear.md) - clears the content and resets the value to the default value
- [basic_json_view::empty](../basic_json_view/empty.md) - the same check on a zero-copy view - [`basic_json_view::empty`](../basic_json_view/empty.md) - the same check on a zero-copy view
## Version history ## Version history
+10 -5
View File
@@ -7,7 +7,12 @@ const_iterator end() const noexcept;
Returns an iterator to one past the last element. Returns an iterator to one past the last element.
![Illustration from cppreference.com](../../images/range-begin-end.svg) <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 ## Return value
@@ -39,11 +44,11 @@ Constant.
## See also ## See also
- [begin](begin.md) returns an iterator to the first element - [`begin`](begin.md) - returns an iterator to the first element
- [cend](cend.md) returns a const iterator to one past the last element - [`cend`](cend.md) - returns a const iterator to one past the last element
- [rend](rend.md) returns a reverse iterator to one before the first element - [`rend`](rend.md) - returns a reverse iterator to one before the first element
- [Iterators](../../features/iterators.md) - the article on iterators - [Iterators](../../features/iterators.md) - the article on iterators
- [basic_json_view::end](../basic_json_view/end.md) - the same iteration on a zero-copy view - [`basic_json_view::end`](../basic_json_view/end.md) - the same iteration on a zero-copy view
## Version history ## Version history
+3 -2
View File
@@ -60,8 +60,9 @@ Constant.
## See also ## See also
- [start_pos](start_pos.md) to access the start position - [`start_pos`](start_pos.md) - to access the start position
- [JSON_DIAGNOSTIC_POSITIONS](../macros/json_diagnostic_positions.md) for an overview of the diagnostic positions - [`JSON_DIAGNOSTIC_POSITIONS`](../macros/json_diagnostic_positions.md) - overview of the supported conversions
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - handling parse errors and locating them in the input
## Version history ## Version history
+2 -2
View File
@@ -204,8 +204,8 @@ Strong exception safety: if an exception occurs, the original value stays intact
## See also ## See also
- [clear](clear.md) clears the contents - [`clear`](clear.md) - clears the contents
- [insert](insert.md) add values to an array/object - [`insert`](insert.md) - add values to an array/object
- [Modifying values](../../features/modifying_values.md) - the article on modifying values - [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history ## Version history
@@ -61,7 +61,7 @@ keep
## See also ## See also
- [dump](dump.md) serializes a JSON value, with an `error_handler_t` parameter to configure invalid UTF-8 handling - [`dump`](dump.md) - serializes a JSON value, with an `error_handler_t` parameter to configure invalid UTF-8 handling
- [Handling invalid UTF-8](../../features/serialization.md#handling-invalid-utf-8) - the article on handling invalid UTF-8 - [Handling invalid UTF-8](../../features/serialization.md#handling-invalid-utf-8) - the article on handling invalid UTF-8
## Version history ## Version history
+8 -1
View File
@@ -40,6 +40,9 @@ classDiagram
style json_exception fill:#CCCCFF 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: Subclasses:
- [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`parse_error`](parse_error.md) for exceptions indicating a parse error
@@ -80,7 +83,11 @@ constructor.
## See also ## See also
[List of exceptions](../../home/exceptions.md) - [List of exceptions](../../home/exceptions.md) - overview of all exceptions thrown by the library
- [Working Without Exceptions](../../features/no_exceptions.md) - using the library without exceptions
- [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - parsing alternatives that do not throw
- [Debugging](../../home/debugging.md) - debugging aids
## Version history ## Version history
+4 -3
View File
@@ -91,10 +91,11 @@ Logarithmic in the size of the JSON object.
## See also ## See also
- [count](count.md) returns the number of occurrences of a key - [`count`](count.md) - returns the number of occurrences of a key
- [contains](contains.md) checks whether a key exists - [`contains`](contains.md) - checks whether a key exists
- [basic_json_view::find](../basic_json_view/find.md) - the same lookup on a zero-copy view (a duplicate key resolves - [`basic_json_view::find`](../basic_json_view/find.md) - the same lookup on a zero-copy view (a duplicate key resolves
to the first member, whereas `parse()` keeps the last) to the first member, whereas `parse()` keeps the last)
- [Element Access](../../features/element_access/index.md#does-this-key-exist) - how to test whether a key exists
## Version history ## Version history
+2 -1
View File
@@ -58,7 +58,8 @@ Empty objects and arrays are flattened to `#!json null` and will not be reconstr
## See also ## See also
- [unflatten](unflatten.md) the reverse function - [`unflatten`](unflatten.md) - the reverse function
- [JSON Pointer](../../features/json_pointer.md#flatten-unflatten) - the article on JSON Pointer and flattening
## Version history ## Version history
+2 -2
View File
@@ -86,8 +86,8 @@ std::string format_as(const BasicJsonType& j)
## See also ## See also
- [dump](dump.md) - [`dump`](dump.md) - serialize a JSON value to a string
- [std::formatter<basic_json>](std_formatter.md) - the `std::format` (C++20) equivalent - [`std::formatter<basic_json>`](std_formatter.md) - the `std::format` (C++20) equivalent
- [Serialization](../../features/serialization.md) - the serialization article - [Serialization](../../features/serialization.md) - the serialization article
## Version history ## Version history
+14 -7
View File
@@ -82,8 +82,11 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
successfully, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict` successfully, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict`
- Throws [parse_error.115](../../home/exceptions.md#jsonexceptionparse_error115) if the text of a high-precision
number (`H`) is not a valid number
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container - Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container
or n-dimensional array cannot be represented by `std::size_t` cannot be represented by `std::size_t` or exceeds the container's `max_size()`, or if the product of the dimensions of
an n-dimensional array overflows
## Complexity ## Complexity
@@ -107,12 +110,16 @@ Linear in the size of the input.
## See also ## See also
- [to_bjdata](to_bjdata.md) create a BJData serialization of a JSON value - [BJData](../../features/binary_formats/bjdata.md) - the format, its byte layout and how values are mapped
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format - [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format - [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
- [from_bson](from_bson.md) create a JSON value from an input in BSON format - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format - [`to_bjdata`](to_bjdata.md) - create a BJData serialization of a JSON value
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format - [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
## Version history ## Version history
+14 -6
View File
@@ -74,6 +74,11 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs, for instance - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs, for instance
an invalid byte, a string that is not valid UTF-8, or an object key that is not a string an invalid byte, a string that is not valid UTF-8, or an object key that is not a string
The UTF-8 validity of strings is always checked, independent of
[`JSON_STRICT_BINARY_UTF8`](../macros/json_strict_binary_utf8.md), because the end of a BON8 string is determined from
its encoding. Duplicate object keys are accepted; the last value wins (see
[BON8](../../features/binary_formats/bon8.md)).
## Complexity ## Complexity
Linear in the size of the input. Linear in the size of the input.
@@ -96,12 +101,15 @@ Linear in the size of the input.
## See also ## See also
- [to_bon8](to_bon8.md) create a BON8 serialization of a JSON value - [BON8](../../features/binary_formats/bon8.md) - the format, its byte layout and how values are mapped
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format - [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format - [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
- [from_bson](from_bson.md) create a JSON value from an input in BSON format - [`to_bon8`](to_bon8.md) - create a BON8 serialization of a JSON value
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format - [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format - [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
## Version history ## Version history
+13 -8
View File
@@ -80,7 +80,8 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
- Throws [`parse_error.110`](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or - Throws [`parse_error.110`](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or
the end of the input was not reached when `strict` was set to true the end of the input was not reached when `strict` was set to true
- Throws [`parse_error.112`](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs (e.g., an - Throws [`parse_error.112`](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs (e.g., an
invalid string or byte array length) invalid string or byte array length, an invalid inner length of a binary value with subtype `0x02`, or a document size
that does not match the content; `strict` does not affect the document size checks)
- Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is - Throws [`parse_error.114`](../../home/exceptions.md#jsonexceptionparse_error114) if an unsupported BSON record type is
encountered encountered
- Throws [`parse_error.113`](../../home/exceptions.md#jsonexceptionparse_error113) if a string value or object key is - Throws [`parse_error.113`](../../home/exceptions.md#jsonexceptionparse_error113) if a string value or object key is
@@ -108,13 +109,17 @@ Linear in the size of the input.
## See also ## See also
- [BSON specification](http://bsonspec.org/spec.html) - [BSON](../../features/binary_formats/bson.md) - the format, its byte layout and how values are mapped
- [to_bson](to_bson.md) for the analogous serialization - [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
- [from_cbor](from_cbor.md) for the related CBOR format - [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
- [from_msgpack](from_msgpack.md) for the related MessagePack format - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [from_ubjson](from_ubjson.md) for the related UBJSON format - [BSON specification](http://bsonspec.org/spec.html) - specification of the BSON format
- [from_bjdata](from_bjdata.md) for the related BJData format - [`to_bson`](to_bson.md) - the analogous serialization
- [from_bon8](from_bon8.md) for the related BON8 format - [`from_cbor`](from_cbor.md) - the related CBOR format
- [`from_msgpack`](from_msgpack.md) - the related MessagePack format
- [`from_ubjson`](from_ubjson.md) - the related UBJSON format
- [`from_bjdata`](from_bjdata.md) - the related BJData format
- [`from_bon8`](from_bon8.md) - the related BON8 format
## Version history ## Version history
+22 -10
View File
@@ -32,8 +32,10 @@ The exact mapping and its limitations are described on a [dedicated page](../../
- an `std::istream` object - an `std::istream` object
- a `FILE` pointer - a `FILE` pointer
- a C-style array of characters - a C-style array of characters (its terminating NUL is read as trailing data: `parse_error.110` unless `strict` is
- a pointer to a null-terminated string of single byte characters `false`)
- a pointer to a null-terminated string of single byte characters (read up to the first 0x00 byte, which is a valid
CBOR byte)
- a container `obj` for which `begin(obj)` and `end(obj)` produce a valid pair of iterators - 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`) (as found via ADL or member functions, with semantics compatible to `std::begin` and `std::end`)
@@ -89,8 +91,14 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if unsupported features from CBOR were
used in the given input or if the input is not valid CBOR used in the given input or if the input is not valid CBOR
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a map key is not a string (keys of - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a map key is not a string (keys of
other types are not supported, as JSON object keys are always strings), or if a string value or object key is not other types are not supported, as JSON object keys are always strings), if the head of a string or byte string is
valid UTF-8 and `error_handler` is `strict` malformed (including a chunk of the wrong type or an indefinite-length string nested inside an indefinite-length
string), or if a string value or object key (or one chunk of an indefinite-length string) is not valid UTF-8 and
`error_handler` is `strict`
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if an array or map announces
a length that `std::size_t` cannot hold, or that equals `std::size_t(-1)` (for example `9B FF FF FF FF FF FF FF FF`)
- Throws [out_of_range.406](../../home/exceptions.md#jsonexceptionout_of_range406) if a floating-point number does not
fit into `number_float_t`
## Complexity ## Complexity
@@ -114,12 +122,16 @@ Linear in the size of the input.
## See also ## See also
- [to_cbor](to_cbor.md) create a CBOR serialization of a JSON value - [CBOR](../../features/binary_formats/cbor.md) - the format, its byte layout and how values are mapped
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format - [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
- [from_bson](from_bson.md) create a JSON value from an input in BSON format - [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format - [`to_cbor`](to_cbor.md) - create a CBOR serialization of a JSON value
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format - [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
## Version history ## Version history
@@ -107,12 +107,16 @@ Linear in the size of the input.
## See also ## See also
- [to_msgpack](to_msgpack.md) create a MessagePack serialization of a JSON value - [MessagePack](../../features/binary_formats/messagepack.md) - the format, its byte layout and how values are mapped
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format - [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
- [from_bson](from_bson.md) create a JSON value from an input in BSON format - [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
- [from_ubjson](from_ubjson.md) create a JSON value from an input in UBJSON format - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format - [`to_msgpack`](to_msgpack.md) - create a MessagePack serialization of a JSON value
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format - [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
- [`from_ubjson`](from_ubjson.md) - create a JSON value from an input in UBJSON format
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
## Version history ## Version history
+21 -10
View File
@@ -79,11 +79,18 @@ Strong guarantee: if an exception is thrown, there are no changes in the JSON va
- Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or - Throws [parse_error.110](../../home/exceptions.md#jsonexceptionparse_error110) if the given input ends prematurely or
the end of the file was not reached when `strict` was set to true the end of the file was not reached when `strict` was set to true
- Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if a parse error occurs - Throws [parse_error.112](../../home/exceptions.md#jsonexceptionparse_error112) if an invalid type marker is read
(including a type marker after `$` of an optimized container, even if its count is 0), or if `$` is not followed by `#`
- Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed - Throws [parse_error.113](../../home/exceptions.md#jsonexceptionparse_error113) if a string could not be parsed
successfully, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict` successfully (negative or non-integer length, `C` followed by a byte above 0x7F), if the count of an optimized
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the size of an optimized container container is negative, or if a string value or object key is not valid UTF-8 and `error_handler` is `strict`
or n-dimensional array cannot be represented by `std::size_t` - Throws [parse_error.115](../../home/exceptions.md#jsonexceptionparse_error115) if the text of a high-precision number
(`H`) is not a valid JSON number
- Throws [out_of_range.406](../../home/exceptions.md#jsonexceptionout_of_range406) if a high-precision number, or a
float64 when `number_float_t` is `float`, does not fit into `number_float_t`
- Throws [out_of_range.408](../../home/exceptions.md#jsonexceptionout_of_range408) if the count of an optimized
container exceeds the capacity of the container (or of `std::size_t`), or if an optimized array of `Z`, `T`, or `F` has
more than 1,048,576 elements
## Complexity ## Complexity
@@ -107,12 +114,16 @@ Linear in the size of the input.
## See also ## See also
- [to_ubjson](to_ubjson.md) create a UBJSON serialization of a JSON value - [UBJSON](../../features/binary_formats/ubjson.md) - the format, its byte layout and how values are mapped
- [from_cbor](from_cbor.md) create a JSON value from an input in CBOR format - [Binary formats](../../features/binary_formats/index.md) - overview and comparison of the supported binary formats
- [from_msgpack](from_msgpack.md) create a JSON value from an input in MessagePack format - [Parsing untrusted input](../../features/parsing/untrusted_input.md) - limits and safe handling of hostile data
- [from_bson](from_bson.md) create a JSON value from an input in BSON format - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [from_bjdata](from_bjdata.md) create a JSON value from an input in BJData format - [`to_ubjson`](to_ubjson.md) - create a UBJSON serialization of a JSON value
- [from_bon8](from_bon8.md) create a JSON value from an input in BON8 format - [`from_cbor`](from_cbor.md) - create a JSON value from an input in CBOR format
- [`from_msgpack`](from_msgpack.md) - create a JSON value from an input in MessagePack format
- [`from_bson`](from_bson.md) - create a JSON value from an input in BSON format
- [`from_bjdata`](from_bjdata.md) - create a JSON value from an input in BJData format
- [`from_bon8`](from_bon8.md) - create a JSON value from an input in BON8 format
## Version history ## Version history
+3 -2
View File
@@ -50,9 +50,10 @@ Constant.
## See also ## See also
- [back](back.md) to access the last element - [`back`](back.md) - to access the last element
- [basic_json_view::front](../basic_json_view/front.md) - the same access on a zero-copy view (document order, not - [`basic_json_view::front`](../basic_json_view/front.md) - the same access on a zero-copy view (document order, not
sorted; duplicate keys are visited) sorted; duplicate keys are visited)
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
## Version history ## Version history
+6 -5
View File
@@ -178,13 +178,14 @@ overload (3).
## See also ## See also
- [get_to](get_to.md) convert and write into a passed value - [`get_to`](get_to.md) - convert and write into a passed value
- [get_ptr](get_ptr.md) get a pointer to the stored value - [`get_ptr`](get_ptr.md) - get a pointer to the stored value
- [get_ref](get_ref.md) get a reference to the stored value - [`get_ref`](get_ref.md) - get a reference to the stored value
- [operator ValueType](operator_ValueType.md) get a value via implicit conversion - [`operator ValueType`](operator_ValueType.md) - get a value via implicit conversion
- [Converting values](../../features/conversions.md) - the type conversions article - [Converting values](../../features/conversions.md) - the type conversions article
- [basic_json_view::get](../basic_json_view/get.md) - the same conversion on a zero-copy view (many types are - [`basic_json_view::get`](../basic_json_view/get.md) - the same conversion on a zero-copy view (many types are
converted without ever building a `basic_json` value) converted without ever building a `basic_json` value)
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - make your own types usable with `get`
## Version history ## Version history
@@ -36,7 +36,7 @@ Constant.
## See also ## See also
- [basic_json](index.md#template-parameters) the class template, with `AllocatorType` as one of its template parameters - [`basic_json`](index.md#template-parameters) - the class template, with `AllocatorType` as one of its template parameters
- [Template Parameter Requirements](../../features/types/template_parameters.md#allocatortype) - the requirements for `AllocatorType` - [Template Parameter Requirements](../../features/types/template_parameters.md#allocatortype) - the requirements for `AllocatorType`
## Version history ## Version history
@@ -42,8 +42,11 @@ Constant.
## See also ## See also
- [get](get.md) get a value (explicit conversion) - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [get_ref](get_ref.md) get a reference to the stored value - [`binary`](binary.md) - create a binary value
- [`is_binary`](is_binary.md) - check whether a value is binary
- [`get`](get.md) - get a value (explicit conversion)
- [`get_ref`](get_ref.md) - get a reference to the stored value
## Version history ## Version history
+2 -1
View File
@@ -86,7 +86,8 @@ Constant.
## See also ## See also
- [get_ref()](get_ref.md) get a reference value - [`get_ref()`](get_ref.md) - get a reference value
- [Converting values](../../features/conversions.md) - getting values out, with or without copying
## Version history ## Version history
+3 -2
View File
@@ -60,9 +60,10 @@ Constant.
## See also ## See also
- [get_ptr()](get_ptr.md) get a pointer value - [`get_ptr()`](get_ptr.md) - get a pointer value
- [basic_json_view::get_string](../basic_json_view/get_string.md) - the closest counterpart on a zero-copy view: a - [`basic_json_view::get_string`](../basic_json_view/get_string.md) - the closest counterpart on a zero-copy view: a
string without a copy, but as a view rather than a reference to a value that must already exist string without a copy, but as a view rather than a reference to a value that must already exist
- [Converting values](../../features/conversions.md) - getting values out, with or without copying
## Version history ## Version history
+5 -4
View File
@@ -68,11 +68,12 @@ Depends on the `json_serializer<ValueType>::from_json()` implementation.
## See also ## See also
- [get](get.md) get a value (explicit conversion) - [`get`](get.md) - get a value (explicit conversion)
- [get_ref](get_ref.md) get a reference to the stored value - [`get_ref`](get_ref.md) - get a reference to the stored value
- [get_ptr](get_ptr.md) get a pointer to the stored value - [`get_ptr`](get_ptr.md) - get a pointer to the stored value
- [Converting values](../../features/conversions.md) - the type conversions article - [Converting values](../../features/conversions.md) - the type conversions article
- [basic_json_view::get_to](../basic_json_view/get_to.md) - the same conversion on a zero-copy view - [`basic_json_view::get_to`](../basic_json_view/get_to.md) - the same conversion on a zero-copy view
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - make your own types usable with `get_to`
## Version history ## Version history
+10 -4
View File
@@ -121,6 +121,7 @@ The class satisfies the following concept requirements:
- [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation - [**json_pointer**](../json_pointer/index.md) - JSON Pointer implementation
- [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON - [**json_serializer**](json_serializer.md) - type of the serializer to for conversions from/to JSON
- [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors - [**error_handler_t**](error_handler_t.md) - type to choose behavior on decoding errors
- [**bjdata_version_t**](bjdata_version_t.md) - type to choose the BJData version to write
- [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags - [**cbor_tag_handler_t**](cbor_tag_handler_t.md) - type to choose how to handle CBOR tags
- **initializer_list_t** - type for initializer lists of `basic_json` values - **initializer_list_t** - type for initializer lists of `basic_json` values
- [**input_format_t**](input_format_t.md) - type to choose the format to parse - [**input_format_t**](input_format_t.md) - type to choose the format to parse
@@ -188,7 +189,7 @@ The class satisfies the following concept requirements:
Functions to inspect the type of a JSON value. Functions to inspect the type of a JSON value.
- [**type**](type.md) - return the type of the JSON value - [**type**](type.md) - return the type of the JSON value
- [**operator value_t**](operator_value_t.md) - return the type of the JSON value - [`operator value_t`](operator_value_t.md) - return the type of the JSON value
- [**type_name**](type_name.md) - return the type as string - [**type_name**](type_name.md) - return the type as string
- [**is_primitive**](is_primitive.md) - return whether the type is primitive - [**is_primitive**](is_primitive.md) - return whether the type is primitive
- [**is_structured**](is_structured.md) - return whether the type is structured - [**is_structured**](is_structured.md) - return whether the type is structured
@@ -217,7 +218,7 @@ Direct access to the stored value of a JSON value.
- [**get_to**](get_to.md) - get a value and write it to a destination - [**get_to**](get_to.md) - get a value and write it to a destination
- [**get_ptr**](get_ptr.md) - get a pointer value - [**get_ptr**](get_ptr.md) - get a pointer value
- [**get_ref**](get_ref.md) - get a reference value - [**get_ref**](get_ref.md) - get a reference value
- [**operator ValueType**](operator_ValueType.md) - get a value - [`operator ValueType`](operator_ValueType.md) - get a value
- [**get_binary**](get_binary.md) - get a binary value - [**get_binary**](get_binary.md) - get a binary value
- [**as_base_class**](as_base_class.md) - access the custom base class - [**as_base_class**](as_base_class.md) - access the custom base class
@@ -358,10 +359,15 @@ Access to the JSON value
## See also ## See also
- [RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format](https://tools.ietf.org/html/rfc8259) - [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 specification of the JSON data interchange format
- [`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 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` - [Zero-copy JSON views](../../features/json_view.md) - when to use a document and a view instead of a `basic_json`
- [Types](../../features/types/index.md) - how JSON values are stored and which types exist
- [Converting values](../../features/conversions.md) - get values out of a JSON value and put values in
- [Creating JSON values](../../features/creating_values.md) - all the ways to build a JSON value
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - convert your own types to and from JSON
## Version history ## Version history
@@ -53,8 +53,9 @@ bon8
## See also ## See also
- [sax_parse](sax_parse.md) generic SAX parse interface, taking an `input_format_t` to select the input format - [`sax_parse`](sax_parse.md) - generic SAX parse interface, taking an `input_format_t` to select the input format
- [cbor_tag_handler_t](cbor_tag_handler_t.md) configures how CBOR tags are treated while parsing - [`cbor_tag_handler_t`](cbor_tag_handler_t.md) - configures how CBOR tags are treated while parsing
- [Binary Formats](../../features/binary_formats/index.md) - CBOR, MessagePack, BSON, and other formats
## Version history ## Version history
+5 -4
View File
@@ -185,10 +185,11 @@ Strong exception safety: if an exception occurs, the original value stays intact
## See also ## See also
- [emplace](emplace.md) add a value to an object - [`emplace`](emplace.md) - add a value to an object
- [emplace_back](emplace_back.md) add a value to an array - [`emplace_back`](emplace_back.md) - add a value to an array
- [push_back](push_back.md) add a value to an array/object - [`push_back`](push_back.md) - add a value to an array/object
- [update](update.md) merges objects - [`update`](update.md) - merges objects
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history ## Version history
@@ -40,6 +40,9 @@ classDiagram
style json_invalid_iterator fill:#CCCCFF 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 ## Member functions
- **what** - returns explanatory string - **what** - returns explanatory string
@@ -66,12 +69,14 @@ classDiagram
## See also ## See also
- [`exception`](exception.md) for the base class of all exceptions thrown by the library - [`exception`](exception.md) - the base class of all exceptions thrown by the library
- [List of iterator errors](../../home/exceptions.md#iterator-errors) - [List of iterator errors](../../home/exceptions.md#iterator-errors) - overview of iterator errors (`invalid_iterator`)
- [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`parse_error`](parse_error.md) - exceptions indicating a parse error
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`type_error`](type_error.md) - exceptions indicating executing a member function with a wrong type
- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - [`out_of_range`](out_of_range.md) - exceptions indicating access out of the defined range
- [`other_error`](other_error.md) for exceptions indicating other library errors - [`other_error`](other_error.md) - exceptions indicating other library errors
- [Exceptions](../../home/exceptions.md) - all exceptions and their error codes
- [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value
## Version history ## Version history
+6 -5
View File
@@ -36,11 +36,12 @@ Constant.
## See also ## See also
- [is_object](is_object.md) checks whether the JSON value is an object - [`is_object`](is_object.md) - checks whether the JSON value is an object
- [is_structured](is_structured.md) checks whether the JSON value is structured (array or object) - [`is_structured`](is_structured.md) - checks whether the JSON value is structured (array or object)
- [type](type.md) returns the type of the JSON value - [`type`](type.md) - returns the type of the JSON value
- [array_t](array_t.md) the type used to store JSON arrays - [`array_t`](array_t.md) - the type used to store JSON arrays
- [basic_json_view::is_array](../basic_json_view/is_array.md) - the same check on a zero-copy view - [`basic_json_view::is_array`](../basic_json_view/is_array.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
+5 -4
View File
@@ -36,10 +36,11 @@ Constant.
## See also ## See also
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive - [Binary values](../../features/binary_values.md) - how binary values and subtypes are handled
- [binary_t](binary_t.md) the type used to store binary values - [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
- [get_binary](get_binary.md) returns a reference to the stored binary value - [`binary_t`](binary_t.md) - the type used to store binary values
- [basic_json_view::is_binary](../basic_json_view/is_binary.md) - the same check on a zero-copy view - [`get_binary`](get_binary.md) - returns a reference to the stored binary value
- [`basic_json_view::is_binary`](../basic_json_view/is_binary.md) - the same check on a zero-copy view
## Version history ## Version history
@@ -36,9 +36,10 @@ Constant.
## See also ## See also
- [boolean_t](boolean_t.md) the type used to store JSON booleans - [`boolean_t`](boolean_t.md) - the type used to store JSON booleans
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive - [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
- [basic_json_view::is_boolean](../basic_json_view/is_boolean.md) - the same check on a zero-copy view - [`basic_json_view::is_boolean`](../basic_json_view/is_boolean.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
@@ -87,8 +87,9 @@ with `allow_exceptions` set to `#!cpp false`: a parse error then yields a discar
## See also ## See also
- [basic_json_view::is_discarded](../basic_json_view/is_discarded.md) - the corresponding check on a zero-copy view, - [`basic_json_view::is_discarded`](../basic_json_view/is_discarded.md) - the corresponding check on a zero-copy view,
which is `#!cpp true` if the view refers to no value which is `#!cpp true` if the view refers to no value
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
+6 -5
View File
@@ -36,11 +36,12 @@ Constant.
## See also ## See also
- [is_array](is_array.md) checks whether the JSON value is an array - [`is_array`](is_array.md) - checks whether the JSON value is an array
- [is_object](is_object.md) checks whether the JSON value is an object - [`is_object`](is_object.md) - checks whether the JSON value is an object
- [type](type.md) returns the type of the JSON value - [`type`](type.md) - returns the type of the JSON value
- [value_t](value_t.md) the enumeration of JSON types - [`value_t`](value_t.md) - the enumeration of JSON types
- [basic_json_view::is_null](../basic_json_view/is_null.md) - the same check on a zero-copy view - [`basic_json_view::is_null`](../basic_json_view/is_null.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
+6 -4
View File
@@ -46,10 +46,12 @@ constexpr bool is_number() const noexcept
## See also ## See also
- [is_number_integer()](is_number_integer.md) check if the value is an integer or unsigned integer number - [`is_number_integer()`](is_number_integer.md) - check if the value is an integer or unsigned integer number
- [is_number_unsigned()](is_number_unsigned.md) check if the value is an unsigned integer number - [`is_number_unsigned()`](is_number_unsigned.md) - check if the value is an unsigned integer number
- [is_number_float()](is_number_float.md) check if the value is a floating-point number - [`is_number_float()`](is_number_float.md) - check if the value is a floating-point number
- [basic_json_view::is_number](../basic_json_view/is_number.md) - the same check on a zero-copy view - [`basic_json_view::is_number`](../basic_json_view/is_number.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
## Version history ## Version history
@@ -37,10 +37,12 @@ Constant.
## See also ## See also
- [is_number()](is_number.md) check if the value is a number - [`is_number()`](is_number.md) - check if the value is a number
- [is_number_integer()](is_number_integer.md) check if the value is an integer or unsigned integer number - [`is_number_integer()`](is_number_integer.md) - check if the value is an integer or unsigned integer number
- [is_number_unsigned()](is_number_unsigned.md) check if the value is an unsigned integer number - [`is_number_unsigned()`](is_number_unsigned.md) - check if the value is an unsigned integer number
- [basic_json_view::is_number_float](../basic_json_view/is_number_float.md) - the same check on a zero-copy view - [`basic_json_view::is_number_float`](../basic_json_view/is_number_float.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
## Version history ## Version history
@@ -37,10 +37,12 @@ Constant.
## See also ## See also
- [is_number()](is_number.md) check if the value is a number - [`is_number()`](is_number.md) - check if the value is a number
- [is_number_unsigned()](is_number_unsigned.md) check if the value is an unsigned integer number - [`is_number_unsigned()`](is_number_unsigned.md) - check if the value is an unsigned integer number
- [is_number_float()](is_number_float.md) check if the value is a floating-point number - [`is_number_float()`](is_number_float.md) - check if the value is a floating-point number
- [basic_json_view::is_number_integer](../basic_json_view/is_number_integer.md) - the same check on a zero-copy view - [`basic_json_view::is_number_integer`](../basic_json_view/is_number_integer.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
## Version history ## Version history
@@ -40,10 +40,12 @@ Constant.
## See also ## See also
- [is_number()](is_number.md) check if the value is a number - [`is_number()`](is_number.md) - check if the value is a number
- [is_number_integer()](is_number_integer.md) check if the value is an integer or unsigned integer number - [`is_number_integer()`](is_number_integer.md) - check if the value is an integer or unsigned integer number
- [is_number_float()](is_number_float.md) check if the value is a floating-point number - [`is_number_float()`](is_number_float.md) - check if the value is a floating-point number
- [basic_json_view::is_number_unsigned](../basic_json_view/is_number_unsigned.md) - the same check on a zero-copy view - [`basic_json_view::is_number_unsigned`](../basic_json_view/is_number_unsigned.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
- [Number Handling](../../features/types/number_handling.md) - how numbers are stored and converted
## Version history ## Version history
+6 -5
View File
@@ -36,11 +36,12 @@ Constant.
## See also ## See also
- [is_array](is_array.md) checks whether the JSON value is an array - [`is_array`](is_array.md) - checks whether the JSON value is an array
- [is_structured](is_structured.md) checks whether the JSON value is structured (array or object) - [`is_structured`](is_structured.md) - checks whether the JSON value is structured (array or object)
- [type](type.md) returns the type of the JSON value - [`type`](type.md) - returns the type of the JSON value
- [object_t](object_t.md) the type used to store JSON objects - [`object_t`](object_t.md) - the type used to store JSON objects
- [basic_json_view::is_object](../basic_json_view/is_object.md) - the same check on a zero-copy view - [`basic_json_view::is_object`](../basic_json_view/is_object.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
@@ -56,13 +56,14 @@ This library extends primitive types to binary types, because binary types are r
## See also ## See also
- [is_structured()](is_structured.md) returns whether the JSON value is structured - [`is_structured()`](is_structured.md) - returns whether the JSON value is structured
- [is_null()](is_null.md) returns whether the JSON value is `null` - [`is_null()`](is_null.md) - returns whether the JSON value is `null`
- [is_string()](is_string.md) returns whether the JSON value is a string - [`is_string()`](is_string.md) - returns whether the JSON value is a string
- [is_boolean()](is_boolean.md) returns whether the JSON value is a boolean - [`is_boolean()`](is_boolean.md) - returns whether the JSON value is a boolean
- [is_number()](is_number.md) returns whether the JSON value is a number - [`is_number()`](is_number.md) - returns whether the JSON value is a number
- [is_binary()](is_binary.md) returns whether the JSON value is a binary array - [`is_binary()`](is_binary.md) - returns whether the JSON value is a binary array
- [basic_json_view::is_primitive](../basic_json_view/is_primitive.md) - the same check on a zero-copy view - [`basic_json_view::is_primitive`](../basic_json_view/is_primitive.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
+5 -4
View File
@@ -36,10 +36,11 @@ Constant.
## See also ## See also
- [is_primitive](is_primitive.md) checks whether the JSON value is primitive - [`is_primitive`](is_primitive.md) - checks whether the JSON value is primitive
- [type](type.md) returns the type of the JSON value - [`type`](type.md) - returns the type of the JSON value
- [string_t](string_t.md) the type used to store JSON strings - [`string_t`](string_t.md) - the type used to store JSON strings
- [basic_json_view::is_string](../basic_json_view/is_string.md) - the same check on a zero-copy view - [`basic_json_view::is_string`](../basic_json_view/is_string.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
@@ -54,10 +54,11 @@ Note that though strings are containers in C++, they are treated as primitive va
## See also ## See also
- [is_primitive()](is_primitive.md) returns whether JSON value is primitive - [`is_primitive()`](is_primitive.md) - returns whether JSON value is primitive
- [is_array()](is_array.md) returns whether the value is an array - [`is_array()`](is_array.md) - returns whether the value is an array
- [is_object()](is_object.md) returns whether the value is an object - [`is_object()`](is_object.md) - returns whether the value is an object
- [basic_json_view::is_structured](../basic_json_view/is_structured.md) - the same check on a zero-copy view - [`basic_json_view::is_structured`](../basic_json_view/is_structured.md) - the same check on a zero-copy view
- [Types](../../features/types/index.md) - the JSON value types and how they are stored
## Version history ## Version history
+5 -4
View File
@@ -54,7 +54,7 @@ using element_type = decltype(*j_object.items().begin());
``` ```
The per-element type (`iteration_proxy_value`) lives in the library's internal `detail` namespace and is The per-element type (`iteration_proxy_value`) lives in the library's internal `detail` namespace and is
intentionally unspecified as a stable, named type -- `decltype` is the supported way to obtain it, but its exact intentionally unspecified as a stable, named type — `decltype` is the supported way to obtain it, but its exact
name/definition may change between versions. name/definition may change between versions.
## Return value ## Return value
@@ -97,10 +97,11 @@ When iterating over an array, `key()` will return the index of the element as st
## See also ## See also
- [begin](begin.md) returns an iterator to the first element - [`begin`](begin.md) - returns an iterator to the first element
- [end](end.md) returns an iterator to one past the last element - [`end`](end.md) - returns an iterator to one past the last element
- [basic_json_view::items](../basic_json_view/items.md) - the same range on a zero-copy view (`#!cpp const auto`, - [`basic_json_view::items`](../basic_json_view/items.md) - the same range on a zero-copy view (`#!cpp const auto`,
not `#!cpp const auto&`: items are produced on the fly; document order, not sorted; duplicate keys are visited) not `#!cpp const auto&`: items are produced on the fly; document order, not sorted; duplicate keys are visited)
- [Iterators](../../features/iterators.md#access-object-keys-during-iteration) - the article on iterating over keys and values
## Version history ## Version history
@@ -57,7 +57,7 @@ same name. Hidden members remain accessible via [`as_base_class`](as_base_class.
## See also ## See also
- [as_base_class](as_base_class.md) - access the custom base class - [`as_base_class`](as_base_class.md) - access the custom base class
- [Template Parameter Requirements](../../features/types/template_parameters.md#custombaseclass) - the requirements for `CustomBaseClass` - [Template Parameter Requirements](../../features/types/template_parameters.md#custombaseclass) - the requirements for `CustomBaseClass`
## Version history ## Version history
@@ -44,10 +44,11 @@ deserializes. See [Template Parameter Requirements](../../features/types/templat
## See also ## See also
- [adl_serializer](../adl_serializer/index.md) the default `json_serializer` - [`adl_serializer`](../adl_serializer/index.md) - the default `json_serializer`
- [get](get.md) explicit type conversion using the `json_serializer`'s `from_json()` method - [`get`](get.md) - explicit type conversion using the `json_serializer`'s `from_json()` method
- [get_to](get_to.md) explicit type conversion into a variable using the `json_serializer`'s `from_json()` method - [`get_to`](get_to.md) - explicit type conversion into a variable using the `json_serializer`'s `from_json()` method
- [Arbitrary Type Conversions](../../features/arbitrary_types.md) - the article on converting between JSON values and arbitrary types - [Arbitrary Type Conversions](../../features/arbitrary_types.md) - the article on converting between JSON values and arbitrary types
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `JSONSerializer` template parameter
## Version history ## Version history
+4 -4
View File
@@ -33,7 +33,7 @@ constant complexity.
## Notes ## Notes
This function does not return the maximal length of a string stored as JSON value -- it returns the maximal number of This function does not return the maximal length of a string stored as JSON value — it returns the maximal number of
string elements the JSON value can store which is `1`. string elements the JSON value can store which is `1`.
## Examples ## Examples
@@ -56,9 +56,9 @@ string elements the JSON value can store which is `1`.
## See also ## See also
- [size](size.md) returns the number of elements - [`size`](size.md) - returns the number of elements
- [array_t](array_t.md) the type used to store JSON arrays - [`array_t`](array_t.md) - the type used to store JSON arrays
- [object_t](object_t.md) the type used to store JSON objects - [`object_t`](object_t.md) - the type used to store JSON objects
## Version history ## Version history
@@ -70,9 +70,10 @@ object operation (looking up a key, or adding one to the patch): logarithmic for
## See also ## See also
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - specification of JSON Merge Patch
- [merge_patch](merge_patch.md) applies a JSON Merge Patch - [`merge_patch`](merge_patch.md) - applies a JSON Merge Patch
- [diff](diff.md) creates a diff as a JSON Patch - [`diff`](diff.md) - creates a diff as a JSON Patch
- [JSON Merge Patch](../../features/merge_patch.md) - the article on JSON Merge Patch
## Version history ## Version history
+28 -7
View File
@@ -39,13 +39,33 @@ Basic guarantee: if an exception is thrown during the operation, the JSON value
## Complexity ## Complexity
Linear in the lengths of `apply_patch`. Linear in the total number of values (including nested ones) in `apply_patch`, times the cost of a key-based object
operation (looking up, adding, or erasing a member): logarithmic for [`json`](../json.md), and linear for
[`ordered_json`](../ordered_json.md) (see [`ordered_map` complexity](../ordered_map.md#complexity)). For
`ordered_json`, patching an object that has `n` members with a patch that has `m` members therefore takes O(n·m). The
cost also includes one copy of `apply_patch` (see the notes below).
## Notes ## Notes
`apply_patch` may be `#!cpp *this` itself or refer to a value contained in `#!cpp *this` (for example, a subobject - `apply_patch` may be `#!cpp *this` itself or refer to a value contained in `#!cpp *this` (for example, a subobject
returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was called, before any modification of returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was called, before any modification of
`#!cpp *this`. `#!cpp *this`. To make this possible, the function copies `apply_patch` before it modifies `#!cpp *this`, so the cost
includes one copy of the patch.
- A merge patch uses `#!json null` to remove a member, so it cannot set a member to `#!json null`: applying
`#!json {"a":null}` to `#!json {"a":1}` gives `#!json {}`.
- Arrays are not merged: an array in the patch replaces the target value as a whole, and a `#!json null` inside an
array is kept as an element. `#!json null` members of the target that the patch does not mention are preserved.
- A `#!json null` in the patch only removes a member; it does not prevent the creation of the enclosing objects.
Applying `#!json {"a":{"b":null}}` to `#!json {}` gives `#!json {"a":{}}` (see example 15 in Appendix A of the RFC).
- If `apply_patch` is not an object, it replaces the target as a whole. In particular, a `#!json null` patch turns the
target into `#!json null`. If `apply_patch` is an object and the target is not, the target is first replaced by an
empty object, so applying `#!json {}` to `#!json 1` gives `#!json {}`.
- A merge patch cannot express every change; for example, it cannot reorder array elements or remove a specific array
element. Use [JSON Patch](../../features/json_patch.md) ([RFC 6902](https://tools.ietf.org/html/rfc6902)) for that.
[`merge_diff`](merge_diff.md) has a matching limitation, see its notes.
- A [discarded](is_discarded.md) value is treated like any other non-object value: a discarded
`apply_patch` turns the target into a discarded value, and an object patch replaces a discarded target by an object
as described above.
## Examples ## Examples
@@ -65,9 +85,10 @@ returned by `#!cpp (*this)[key]`); it is read as it was when `merge_patch()` was
## See also ## See also
- [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - specification of JSON Merge Patch
- [patch](patch.md) apply a JSON patch - [`patch`](patch.md) - apply a JSON patch
- [merge_diff](merge_diff.md) creates a diff as a JSON Merge Patch - [`merge_diff`](merge_diff.md) - creates a diff as a JSON Merge Patch
- [JSON Merge Patch](../../features/merge_patch.md) - the article on JSON Merge Patch
## Version history ## Version history
+5 -2
View File
@@ -48,8 +48,11 @@ Constant.
## See also ## See also
- [**NLOHMANN_JSON_VERSION_MAJOR**/**NLOHMANN_JSON_VERSION_MINOR**/**NLOHMANN_JSON_VERSION_PATCH**](../macros/nlohmann_json_version_major.md) - [`NLOHMANN_JSON_VERSION_MAJOR`](../macros/nlohmann_json_version_major.md) /
\- library version information [`NLOHMANN_JSON_VERSION_MINOR`](../macros/nlohmann_json_version_major.md) /
[`NLOHMANN_JSON_VERSION_PATCH`](../macros/nlohmann_json_version_major.md) - library version information
- [Integration](../../integration/index.md) - integrate the library
- [Supported Macros](../../features/macros.md) - guide to all supported macros
## Version history ## Version history
@@ -84,10 +84,11 @@ Floating-point number values are stored directly inside a `basic_json` type.
## See also ## See also
- [number_integer_t](number_integer_t.md) the type used to store JSON integer numbers - [`number_integer_t`](number_integer_t.md) - the type used to store JSON integer numbers
- [number_unsigned_t](number_unsigned_t.md) the type used to store JSON unsigned integer numbers - [`number_unsigned_t`](number_unsigned_t.md) - the type used to store JSON unsigned integer numbers
- [is_number_float](is_number_float.md) checks whether the JSON value is a floating-point number - [`is_number_float`](is_number_float.md) - checks whether the JSON value is a floating-point number
- [Number Handling](../../features/types/number_handling.md) - the article on number handling - [Number Handling](../../features/types/number_handling.md) - the article on number handling
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the number template parameters
## Version history ## Version history
@@ -80,10 +80,11 @@ Integer number values are stored directly inside a `basic_json` type.
## See also ## See also
- [number_unsigned_t](number_unsigned_t.md) the type used to store JSON unsigned integer numbers - [`number_unsigned_t`](number_unsigned_t.md) - the type used to store JSON unsigned integer numbers
- [number_float_t](number_float_t.md) the type used to store JSON floating-point numbers - [`number_float_t`](number_float_t.md) - the type used to store JSON floating-point numbers
- [is_number_integer](is_number_integer.md) checks whether the JSON value is a signed integer number - [`is_number_integer`](is_number_integer.md) - checks whether the JSON value is a signed integer number
- [Number Handling](../../features/types/number_handling.md) - the article on number handling - [Number Handling](../../features/types/number_handling.md) - the article on number handling
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the number template parameters
## Version history ## Version history
@@ -82,10 +82,11 @@ Integer number values are stored directly inside a `basic_json` type.
## See also ## See also
- [number_integer_t](number_integer_t.md) the type used to store JSON integer numbers - [`number_integer_t`](number_integer_t.md) - the type used to store JSON integer numbers
- [number_float_t](number_float_t.md) the type used to store JSON floating-point numbers - [`number_float_t`](number_float_t.md) - the type used to store JSON floating-point numbers
- [is_number_unsigned](is_number_unsigned.md) checks whether the JSON value is an unsigned integer number - [`is_number_unsigned`](is_number_unsigned.md) - checks whether the JSON value is an unsigned integer number
- [Number Handling](../../features/types/number_handling.md) - the article on number handling - [Number Handling](../../features/types/number_handling.md) - the article on number handling
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the number template parameters
## Version history ## Version history
@@ -27,8 +27,10 @@ and [`default_object_comparator_t`](default_object_comparator_t.md) otherwise.
## See also ## See also
- [object_t](object_t.md) the type used to store JSON objects - [`object_t`](object_t.md) - the type used to store JSON objects
- [default_object_comparator_t](default_object_comparator_t.md) the fallback comparator used when `object_t` has no `key_compare` member type - [`default_object_comparator_t`](default_object_comparator_t.md) - the fallback comparator used when `object_t` has no `key_compare` member type
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ObjectType` template parameter
- [Object order](../../features/object_order.md) - preserve the insertion order of keys
## Version history ## Version history
+6 -4
View File
@@ -20,7 +20,7 @@ To store objects in C++, a type is defined by the template parameters described
`ObjectType` `ObjectType`
: the container to store objects. Its template parameters must have the same order and meaning as those of : the container to store objects. Its template parameters must have the same order and meaning as those of
`std::map`; in particular, the third parameter is a comparator. `#!cpp std::unordered_map`, whose third parameter `std::map`; in particular, the third parameter is a comparator. `#!cpp std::unordered_map`, whose third parameter
is a hash function, therefore needs an adapter -- see is a hash function, therefore needs an adapter — see
[Template Parameter Requirements](../../features/types/template_parameters.md#objecttype) for the full list of [Template Parameter Requirements](../../features/types/template_parameters.md#objecttype) for the full list of
requirements, an adapter example, and the containers that are known to work. requirements, an adapter example, and the containers that are known to work.
@@ -125,10 +125,12 @@ the object is silently converted as an array of key-value pairs, which is incorr
## See also ## See also
- [array_t](array_t.md) the type used to store JSON arrays - [`array_t`](array_t.md) - the type used to store JSON arrays
- [string_t](string_t.md) the type used to store JSON strings - [`string_t`](string_t.md) - the type used to store JSON strings
- [object_comparator_t](object_comparator_t.md) the comparator used to order object keys - [`object_comparator_t`](object_comparator_t.md) - the comparator used to order object keys
- [Object Order](../../features/object_order.md) - the article on object key ordering - [Object Order](../../features/object_order.md) - the article on object key ordering
- [Types](../../features/types/index.md) - how objects are stored
- [Template Parameter Requirements](../../features/types/template_parameters.md) - requirements on the `ObjectType` template parameter
## Version history ## Version history
@@ -123,8 +123,9 @@ interpreted as `object_t::value_type` or `std::initializer_list<basic_json>`, se
## See also ## See also
- [emplace_back](emplace_back.md) add a value to an array - [`emplace_back`](emplace_back.md) - add a value to an array
- [push_back](push_back.md) add a value to an array/object - [`push_back`](push_back.md) - add a value to an array/object
- [Modifying values](../../features/modifying_values.md) - the article on modifying values
## Version history ## Version history
+3 -2
View File
@@ -45,8 +45,9 @@ Linear.
## See also ## See also
- [basic_json](basic_json.md) create a JSON value - [`basic_json`](basic_json.md) - create a JSON value
- [swap](swap.md) exchanges the contents of two JSON values - [`swap`](swap.md) - exchanges the contents of two JSON values
- [Creating JSON values](../../features/creating_values.md) - ways to create and assign JSON values
## Version history ## Version history
+14 -9
View File
@@ -137,10 +137,13 @@ Strong exception safety: if an exception occurs, the original value stays intact
When the JSON pointer traverses intermediate levels that don't exist at all yet (not just a missing When the JSON pointer traverses intermediate levels that don't exist at all yet (not just a missing
leaf), each missing level is created as an array or an object depending on whether the corresponding leaf), each missing level is created as an array or an object depending on whether the corresponding
pointer token parses as a non-negative integer: a numeric token creates an array, a non-numeric token pointer token is a valid array index: the token `0`, a sequence of digits that does not begin with `0`,
creates an object. For example, on an initially `#!json null` value, `/foo/0/0/0` creates nested arrays, or the token `-` creates an array, and every other token creates an object. For example, on an
while `/foo/one/one/one` creates nested objects. This is not specified by the JSON Pointer RFC; it is initially `#!json null` value, `/foo/0/0/0` creates nested arrays, while `/foo/one/one/one` creates
this library's own, intentional disambiguation rule. See also [JSON Pointer](../../features/json_pointer.md). nested objects. Tokens such as `01` or the empty token cannot be array indices (cf. RFC 6901, Sect. 4)
and therefore create objects, just as they would if the level already existed as an object. This is not
specified by the JSON Pointer RFC; it is this library's own, intentional disambiguation rule. See also
[JSON Pointer](../../features/json_pointer.md).
!!! warning "Deprecation" !!! warning "Deprecation"
@@ -271,13 +274,15 @@ Strong exception safety: if an exception occurs, the original value stays intact
## See also ## See also
- documentation on [unchecked access](../../features/element_access/unchecked_access.md) - [Unchecked access](../../features/element_access/unchecked_access.md) - element access without range checking
- documentation on [runtime assertions](../../features/assertions.md) - [Runtime assertions](../../features/assertions.md) - assertions guarding against undefined behavior
- see [`at`](at.md) for access by reference with range checking - [`at`](at.md) - access by reference with range checking
- see [`value`](value.md) for access with default value - [`value`](value.md) - access with default value
- [basic_json_view::operator[]](../basic_json_view/operator%5B%5D.md) - the same access on a zero-copy view (a duplicate - [`basic_json_view::operator[]`](../basic_json_view/operator%5B%5D.md) - the same access on a zero-copy view (a duplicate
key resolves to the first member, whereas `parse()` keeps the last; a missing key gives a discarded view instead of key resolves to the first member, whereas `parse()` keeps the last; a missing key gives a discarded view instead of
undefined behavior) undefined behavior)
- [Element Access](../../features/element_access/index.md) - overview of all ways to access elements
- [JSON Pointer](../../features/json_pointer.md) - access nested values with a pointer
## Version history ## Version history
@@ -84,7 +84,7 @@ Linear in the size of the JSON value.
## See also ## See also
- [get](get.md) get a value (explicit conversion) - [`get`](get.md) - get a value (explicit conversion)
- [Converting values](../../features/conversions.md) - the type conversions article - [Converting values](../../features/conversions.md) - the type conversions article
## Version history ## Version history
@@ -168,9 +168,9 @@ Linear.
## See also ## See also
- [operator!=](operator_ne.md) compare for inequality - [`operator!=`](operator_ne.md) - compare for inequality
- [operator<=>](operator_spaceship.md) comparison: 3-way (C++20) - [`operator<=>`](operator_spaceship.md) - comparison: 3-way (C++20)
- [basic_json_view::operator==](../basic_json_view/operator_eq.md) - the same comparison on a zero-copy view, without - [`basic_json_view::operator==`](../basic_json_view/operator_eq.md) - the same comparison on a zero-copy view, without
building a `basic_json` value for it building a `basic_json` value for it
## Version history ## Version history
@@ -93,7 +93,7 @@ Linear.
## See also ## See also
- [**operator<=>**](operator_spaceship.md) comparison: 3-way - [`operator<=>`](operator_spaceship.md) - comparison: 3-way
## Version history ## Version history
@@ -83,7 +83,7 @@ Linear.
## See also ## See also
- [**operator<=>**](operator_spaceship.md) comparison: 3-way - [`operator<=>`](operator_spaceship.md) - comparison: 3-way
## Version history ## Version history
@@ -94,7 +94,7 @@ Linear.
## See also ## See also
- [**operator<=>**](operator_spaceship.md) comparison: 3-way - [`operator<=>`](operator_spaceship.md) - comparison: 3-way
## Version history ## Version history
@@ -94,7 +94,7 @@ Linear.
## See also ## See also
- [**operator<=>**](operator_spaceship.md) comparison: 3-way - [`operator<=>`](operator_spaceship.md) - comparison: 3-way
## Version history ## Version history
@@ -93,9 +93,9 @@ Linear.
## See also ## See also
- [operator==](operator_eq.md) comparison: equal - [`operator==`](operator_eq.md) - comparison: equal
- [operator<=>](operator_spaceship.md) comparison: 3-way (C++20) - [`operator<=>`](operator_spaceship.md) - comparison: 3-way (C++20)
- [basic_json_view::operator!=](../basic_json_view/operator_ne.md) - the same comparison on a zero-copy view, without - [`basic_json_view::operator!=`](../basic_json_view/operator_ne.md) - the same comparison on a zero-copy view, without
building a `basic_json` value for it building a `basic_json` value for it
## Version history ## Version history
@@ -88,12 +88,12 @@ Linear.
## See also ## See also
- [**operator==**](operator_eq.md) - comparison: equal - [`operator==`](operator_eq.md) - comparison: equal
- [**operator!=**](operator_ne.md) - comparison: not equal - [`operator!=`](operator_ne.md) - comparison: not equal
- [**operator<**](operator_lt.md) - comparison: less than - [`operator<`](operator_lt.md) - comparison: less than
- [**operator<=**](operator_le.md) - comparison: less than or equal - [`operator<=`](operator_le.md) - comparison: less than or equal
- [**operator>**](operator_gt.md) - comparison: greater than - [`operator>`](operator_gt.md) - comparison: greater than
- [**operator>=**](operator_ge.md) - comparison: greater than or equal - [`operator>=`](operator_ge.md) - comparison: greater than or equal
## Version history ## Version history
@@ -49,8 +49,9 @@ Constant.
## See also ## See also
- [type](type.md) named member function equivalent to this implicit conversion operator - [`type`](type.md) - named member function equivalent to this implicit conversion operator
- [value_t](value_t.md) the enumeration of JSON types - [`value_t`](value_t.md) - the enumeration of JSON types
- [Types](../../features/types/index.md) - the JSON value types
## Version history ## Version history
+11 -6
View File
@@ -40,6 +40,9 @@ classDiagram
style json_other_error fill:#CCCCFF 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 ## Member functions
- **what** - returns explanatory string - **what** - returns explanatory string
@@ -66,12 +69,14 @@ classDiagram
## See also ## See also
- [`exception`](exception.md) for the base class of all exceptions thrown by the library - [`exception`](exception.md) - the base class of all exceptions thrown by the library
- [List of other errors](../../home/exceptions.md#further-exceptions) - [List of other errors](../../home/exceptions.md#further-exceptions) - overview of further errors (`other_error`)
- [`parse_error`](parse_error.md) for exceptions indicating a parse error - [`parse_error`](parse_error.md) - exceptions indicating a parse error
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`invalid_iterator`](invalid_iterator.md) - exceptions indicating errors with iterators
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`type_error`](type_error.md) - exceptions indicating executing a member function with a wrong type
- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - [`out_of_range`](out_of_range.md) - exceptions indicating access out of the defined range
- [Exceptions](../../home/exceptions.md) - all exceptions and their error codes
- [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value
## Version history ## Version history
@@ -41,6 +41,9 @@ classDiagram
style json_out_of_range fill:#CCCCFF 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 ## Member functions
- **what** - returns explanatory string - **what** - returns explanatory string
@@ -67,12 +70,15 @@ classDiagram
## See also ## See also
- [`exception`](exception.md) for the base class of all exceptions thrown by the library - [`exception`](exception.md) - the base class of all exceptions thrown by the library
- [List of out-of-range errors](../../home/exceptions.md#out-of-range) - [List of out-of-range errors](../../home/exceptions.md#out-of-range) - overview of out-of-range errors
- [`parse_error`](parse_error.md) for exceptions indicating a parse error (`out_of_range`)
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`parse_error`](parse_error.md) - exceptions indicating a parse error
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`invalid_iterator`](invalid_iterator.md) - exceptions indicating errors with iterators
- [`other_error`](other_error.md) for exceptions indicating other library errors - [`type_error`](type_error.md) - exceptions indicating executing a member function with a wrong type
- [`other_error`](other_error.md) - exceptions indicating other library errors
- [Exceptions](../../home/exceptions.md) - all exceptions and their error codes
- [`JSON_DIAGNOSTICS`](../macros/json_diagnostics.md) - extended exception messages with the path of the failing value
## Version history ## Version history
+9 -3
View File
@@ -282,15 +282,21 @@ outside of a string, invalid) byte; see the [FAQ entry](../../home/faq.md#nul-by
## See also ## See also
- [accept](accept.md) - check if the input is valid JSON - [`accept`](accept.md) - check if the input is valid JSON
- [sax_parse](sax_parse.md) - parse input using the SAX interface - [`sax_parse`](sax_parse.md) - parse input using the SAX interface
- [operator>>](../operator_gtgt.md) - deserialize from stream - [`operator>>`](../operator_gtgt.md) - deserialize from stream
- [`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) - opt in to rejecting a NUL byte in the input - [`JSON_STRICT_NUL_HANDLING`](../macros/json_strict_nul_handling.md) - opt in to rejecting a NUL byte in the input
instead of treating it as end of input instead of treating it as end of input
- [`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md) - read a `std::istream` one character - [`JSON_DISABLE_STREAM_BULK_SCAN`](../macros/json_disable_stream_bulk_scan.md) - read a `std::istream` one character
at a time at a time
- [`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) - read a `FILE*` with the locking stdio - [`JSON_DISABLE_UNLOCKED_FILE_IO`](../macros/json_disable_unlocked_file_io.md) - read a `FILE*` with the locking stdio
functions functions
- [Parsing](../../features/parsing/index.md) - overview of the parsing functions
- [Comments](../../features/comments.md) - ignore `//` and `/* */` comments while parsing
- [Trailing Commas](../../features/trailing_commas.md) - accept trailing commas in arrays and objects
- [Parser Callbacks](../../features/parsing/parser_callbacks.md) - filter or inspect values while parsing
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - handling parse errors and locating them in the input
- [Parsing Untrusted Input](../../features/parsing/untrusted_input.md) - limits and checks for input you do not control
## Version history ## Version history
+11 -6
View File
@@ -43,6 +43,9 @@ classDiagram
style json_parse_error fill:#CCCCFF 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 ## Member functions
- **what** - returns explanatory string - **what** - returns explanatory string
@@ -75,12 +78,14 @@ or the end of file. This also holds true when reading a byte vector for binary f
## See also ## See also
- [`exception`](exception.md) for the base class of all exceptions thrown by the library - [`exception`](exception.md) - the base class of all exceptions thrown by the library
- [List of parse errors](../../home/exceptions.md#parse-errors) - [List of parse errors](../../home/exceptions.md#parse-errors) - overview of parse errors (`parse_error`)
- [`invalid_iterator`](invalid_iterator.md) for exceptions indicating errors with iterators - [`invalid_iterator`](invalid_iterator.md) - exceptions indicating errors with iterators
- [`type_error`](type_error.md) for exceptions indicating executing a member function with a wrong type - [`type_error`](type_error.md) - exceptions indicating executing a member function with a wrong type
- [`out_of_range`](out_of_range.md) for exceptions indicating access out of the defined range - [`out_of_range`](out_of_range.md) - exceptions indicating access out of the defined range
- [`other_error`](other_error.md) for exceptions indicating other library errors - [`other_error`](other_error.md) - exceptions indicating other library errors
- [Parsing and Exceptions](../../features/parsing/parse_exceptions.md) - handling parse errors and locating them in the input
- [Working Without Exceptions](../../features/no_exceptions.md) - error handling when exceptions are disabled
## Version history ## Version history
Loaded 100 of 482 files, more files were not shown because too many files have changed in this diff. Show more