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>
This commit is contained in:
1 parent
2bb2feeef4
commit
a47170346a
417 files changed
+11100
-3041
No files matched your search
@@ -18,6 +18,40 @@ Consider the following JSON document
|
||||
}
|
||||
```
|
||||
|
||||
Select a pointer (or a node of the tree) to walk it through this document; each segment of the pointer goes one level
|
||||
deeper. The table below lists the same pointers.
|
||||
|
||||
<div class="nj-pointer-walk" data-nj-pointer-walk data-doc="{"array":["A","B","C"],"nested":{"one":1,"two":2,"three":[true,false]}}" role="group" aria-label="Pointer walker for the example document">
|
||||
<p class="nj-pointer-static">Highlighted: the path of the pointer <code>/nested/three/1</code>, which identifies <code>false</code>.</p>
|
||||
<ul class="nj-pointer-tree">
|
||||
<li data-p="" class="is-on"><span class="nj-pointer-n"><span class="nj-pointer-k">root</span> <span class="nj-pointer-t">object</span></span>
|
||||
<ul>
|
||||
<li data-p="/array" class="is-pass"><span class="nj-pointer-n"><span class="nj-pointer-k">"array"</span> <span class="nj-pointer-t">array</span></span>
|
||||
<ul>
|
||||
<li data-p="/array/0"><span class="nj-pointer-n"><span class="nj-pointer-k">0</span>: <span class="nj-pointer-v nj-pointer-v--s">"A"</span></span></li>
|
||||
<li data-p="/array/1"><span class="nj-pointer-n"><span class="nj-pointer-k">1</span>: <span class="nj-pointer-v nj-pointer-v--s">"B"</span></span></li>
|
||||
<li data-p="/array/2"><span class="nj-pointer-n"><span class="nj-pointer-k">2</span>: <span class="nj-pointer-v nj-pointer-v--s">"C"</span></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li data-p="/nested" class="is-on"><span class="nj-pointer-n"><span class="nj-pointer-k">"nested"</span> <span class="nj-pointer-t">object</span></span>
|
||||
<ul>
|
||||
<li data-p="/nested/one" class="is-pass"><span class="nj-pointer-n"><span class="nj-pointer-k">"one"</span>: <span class="nj-pointer-v nj-pointer-v--n">1</span></span></li>
|
||||
<li data-p="/nested/two" class="is-pass"><span class="nj-pointer-n"><span class="nj-pointer-k">"two"</span>: <span class="nj-pointer-v nj-pointer-v--n">2</span></span></li>
|
||||
<li data-p="/nested/three" class="is-on"><span class="nj-pointer-n"><span class="nj-pointer-k">"three"</span> <span class="nj-pointer-t">array</span></span>
|
||||
<ul>
|
||||
<li data-p="/nested/three/0" class="is-pass"><span class="nj-pointer-n"><span class="nj-pointer-k">0</span>: <span class="nj-pointer-v nj-pointer-v--b">true</span></span></li>
|
||||
<li data-p="/nested/three/1" class="is-on is-target"><span class="nj-pointer-n"><span class="nj-pointer-k">1</span>: <span class="nj-pointer-v nj-pointer-v--b">false</span></span></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>The highlighted nodes are the path from the root to the selected level, and the line below the tree shows the value the pointer resolves to. Select a segment in the pointer bar to stop at a shallower level, or a node of the tree to select its pointer.</p>
|
||||
|
||||
Then every value inside the JSON document can be identified as follows:
|
||||
|
||||
| JSON Pointer | JSON value |
|
||||
@@ -138,12 +172,22 @@ The reverse function, [`unflatten`](../api/basic_json/unflatten.md) recreates th
|
||||
auto j_original = j_flat.unflatten();
|
||||
```
|
||||
|
||||
Each leaf of the document becomes one key of the flat object, and `unflatten()` reverses the mapping:
|
||||
|
||||
<div class="nj-fig-wrap" markdown>
|
||||
--8<-- "images/json_pointer_flatten.svg"
|
||||
</div>
|
||||
|
||||
<p class="nj-caption" markdown>Left: the example document as a tree; right: the flat object it becomes. `flatten()` converts from left to right, `unflatten()` from right to left.</p>
|
||||
|
||||
## See also
|
||||
|
||||
- Class [`json_pointer`](../api/json_pointer/index.md)
|
||||
- Functions [`value`](../api/basic_json/value.md), [`contains`](../api/basic_json/contains.md), and
|
||||
[`at`](../api/basic_json/at.md) accept JSON Pointers; see [Nested values](element_access/default_value.md#nested-values)
|
||||
- Function [`flatten`](../api/basic_json/flatten.md)
|
||||
- Function [`unflatten`](../api/basic_json/unflatten.md)
|
||||
- [`json_pointer`](../api/json_pointer/index.md) - the JSON Pointer class
|
||||
- [Nested values](element_access/default_value.md#nested-values) - [`value`](../api/basic_json/value.md),
|
||||
[`contains`](../api/basic_json/contains.md), and [`at`](../api/basic_json/at.md) accept JSON Pointers
|
||||
- [`flatten`](../api/basic_json/flatten.md) - convert a value to an object of JSON Pointers and primitive values
|
||||
- [`unflatten`](../api/basic_json/unflatten.md) - restore a value from a flattened object
|
||||
- [JSON Patch](json_patch.md) - paths inside a patch are JSON Pointers
|
||||
- [JSON Merge Patch](merge_patch.md) - an alternative patch format that does not use JSON Pointer
|
||||
- [`operator""_json_pointer`](../api/operator_literal_json_pointer.md) - user-defined literal to create a JSON pointer
|
||||
- [Element Access](element_access/index.md) - other ways to access elements
|
||||
Reference in new issue
Block a user