Files
json/docs/mkdocs/docs/api/basic_json/boolean_t.md
T
Niels Lohmann 526b6d3fd6 Review and extend the documentation, and check it in CI
A review of all documentation pages found factual errors, dead links,
missing cross-references, and gaps in examples. This fixes them and adds
checks so the same problems are caught automatically.

Fixes:
- wrong signatures and version histories (operator!= C++20 member,
  binary() subtype type, get<PointerType>(), JSON_NO_THREAD_LOCAL, ...)
- stale descriptions (number parsing since #5283, UBJSON table, SAX
  example that no longer compiled, tsl::ordered_map advice)
- dead internal and external links; repology.org badges (the domain is
  suspended) replaced by badges that query the registries directly
- deprecation notes link the migration guide; the guide itself fixed

Additions:
- "See also" sections, cross-references, 25 runnable examples, 12
  Mermaid diagrams, new API pages for json_pointer::operator<=> and
  byte_container_with_subtype::operator==/!=
- landing page, guides for untrusted input and performance
- "unreleased" badge after versions newer than the latest release

Checks:
- strict documentation build (broken links/anchors fail it); CI and
  the publish workflow fetch the full history the build needs
- weekly external link check, Mermaid syntax check in CI
- check_structure.py: example titles, heading levels, alt texts,
  header links, docset index coverage; its unused-example check works
  again
- all examples produce the same output on every platform

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
2026-09-29 17:05:35 +02:00

1.4 KiB

nlohmann::basic_json::boolean_t

using boolean_t = BooleanType;

The type used to store JSON booleans.

RFC 8259 implicitly describes a boolean as a type which differentiates the two literals #!json true and #!json false.

To store boolean values in C++, a type is defined by the template parameter BooleanType which chooses the type to use.

Template parameters

BooleanType
the type to store booleans. As it is stored directly inside a basic_json value (in a union), it must be a trivially default-constructible, trivially copyable, and trivially destructible type that is convertible to and from #!cpp bool. See Template Parameter Requirements.

Notes

Default type

With the default values for BooleanType (#!cpp bool), the default value for boolean_t is #!cpp bool.

Storage

Boolean values are stored directly inside a basic_json type.

Examples

??? example

The following code shows that `boolean_t` is by default, a typedef to `#!cpp bool`.
 
```cpp
--8<-- "examples/boolean_t.cpp"
```

Output:

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

See also

  • is_boolean checks whether the JSON value is a boolean

Version history

  • Added in version 1.0.0.