diff --git a/docs/mkdocs/docs/api/basic_json_document/save.md b/docs/mkdocs/docs/api/basic_json_document/save.md index a80927c0c..f69d5c9f8 100644 --- a/docs/mkdocs/docs/api/basic_json_document/save.md +++ b/docs/mkdocs/docs/api/basic_json_document/save.md @@ -58,9 +58,10 @@ up in the image. ## Notes **Format.** The image begins with a 64-byte header (the magic bytes `#!cpp "NJVI"`, a version number, the node count, -and the sizes of the text and the decoded strings, all little-endian), followed by the nodes (16 bytes each), the -text and a `#!cpp '\0'`, and the decoded strings and a `#!cpp '\0'`. [`load`](load.md) checks the header, and the -sizes it describes, before reading anything else -- see [`load`'s Exceptions](load.md#exceptions). +and the sizes of the text and the decoded strings, all little-endian), followed by the nodes +([16 bytes each](../../home/architecture.md#node-index-of-json-views)), the text and a `#!cpp '\0'`, and the decoded +strings and a `#!cpp '\0'`. [`load`](load.md) checks the header, and the sizes it describes, before reading anything +else -- see [`load`'s Exceptions](load.md#exceptions). !!! warning "Experimental" diff --git a/docs/mkdocs/docs/home/architecture.md b/docs/mkdocs/docs/home/architecture.md index 3329998f5..2453b26db 100644 --- a/docs/mkdocs/docs/home/architecture.md +++ b/docs/mkdocs/docs/home/architecture.md @@ -259,6 +259,14 @@ edited: - Views of read-only documents compile without any of this: how views walk the index is a template parameter (`navigation`). +Images ([`save`](../api/basic_json_document/save.md) and [`load`](../api/basic_json_document/load.md), +[`detail/view/image.hpp`](https://github.com/nlohmann/json/blob/develop/include/nlohmann/detail/view/image.hpp)) store +the nodes as they are: a 64-byte header (the magic bytes `NJVI`, a format version, the sizes, and reserved bytes that +must be zero), the nodes, the text, and the decoded strings. An edited document is first written in document order, as +the parser would have written it (without links), and the numbers of the hash indexes are cleared, since `load` +rebuilds the indexes. So a change of the node layout is a change of the image format: it must raise `image_version`, +and `load` then rejects images of other versions (`parse_error.116`) instead of misreading them. + ## Input adapters Input is read via **input adapters** that abstract a source. Every input adapter provides this interface: