Files
json/docs/mkdocs/docs/api/basic_json_view/is_binary.md
T
Niels Lohmann 6d3f0dae96 Apply the review's wording fixes to the json_view documentation
- Copying is disabled because of its cost, not because of two documents
  borrowing the same buffer; the unique_ptr follows from move-only.
- Inputs: streams, FILE*, and wide characters (strings, arrays, pointers)
  are all supported and owned; point to parse_copy() for owned copies.
- The error replay only runs for failing input, builds no values, and is
  skipped with allow_exceptions = false.
- read() writes copied inputs into the previous owned copy.
- Views can dangle like std::string_view, and why there is no
  shared/weak pointer design.
- The 4 GiB limit (16-byte nodes, 16-byte scanner steps), streams being
  read to the end first, which macros apply, why materialize() has no
  source positions, and wording nits (accept() vs basic_json::accept(),
  is_binary, is_discarded, see-also lists, size table, "back into").

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-10-17 08:30:46 +02:00

1.1 KiB

nlohmann::basic_json_view::is_binary

bool is_binary() const noexcept;

This function always returns #!cpp false: a document is only ever parsed from JSON text, never from CBOR or the other binary formats, and a JSON text has no binary values, so a view can never refer to one. The function exists for interface parity with BasicJsonType::is_binary.

Return value

#!cpp false, always.

Exception safety

No-throw guarantee: this function never throws exceptions.

Complexity

Constant.

Examples

??? example

The example below classifies several parsed documents by the type of their root value, without materializing any
of them into a `BasicJsonType` value.

```cpp
--8<-- "examples/basic_json_view__type_predicates.cpp"
```

Output:

```json
--8<-- "examples/basic_json_view__type_predicates.output"
```

See also

Version history

  • Added in version 3.13.0.