mirror of
https://github.com/nlohmann/json.git
synced 2026-10-02 20:50:32 +00:00
Merge branch 'json-view/08-view-builder' into json-view/10-view-document
Conflicts in the See also lists of nine basic_json pages, is_discarded.md, and features/index.md, where develop (#5638) and this branch both added entries: kept both. Ran make amalgamate. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -55,7 +55,7 @@ with `allow_exceptions` set to `#!cpp false`: a parse error then yields a discar
|
||||
|
||||
## Examples
|
||||
|
||||
??? example
|
||||
??? example "Example: `is_discarded()` for ordinary JSON values"
|
||||
|
||||
The following code exemplifies `is_discarded()` for all JSON types.
|
||||
|
||||
@@ -69,6 +69,22 @@ with `allow_exceptions` set to `#!cpp false`: a parse error then yields a discar
|
||||
--8<-- "examples/is_discarded.output"
|
||||
```
|
||||
|
||||
??? example "Example: discarded values from parsing"
|
||||
|
||||
The following code shows the two situations in which a discarded value can be observed: parsing invalid JSON with
|
||||
`allow_exceptions` set to `#!cpp false`, and a parser callback that discards the top-level value (which is replaced
|
||||
by `#!json null` and therefore does *not* remain discarded).
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/is_discarded__parse.cpp"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/is_discarded__parse.output"
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [basic_json_view::is_discarded](../basic_json_view/is_discarded.md) - the corresponding check on a zero-copy view,
|
||||
|
||||
Reference in New Issue
Block a user