Standard Template Library Support
February 20, 2026 ยท View on GitHub
Glaze uses C++20 concepts to not only support the standard template library, but also other libraries or custom types that conform to the same interface.
Array Types
Array types logically convert to JSON array values. Concepts are used to allow various containers and even user containers if they match standard library interfaces.
std::tuplestd::arraystd::vectorstd::dequestd::liststd::forward_liststd::spanstd::setstd::unordered_set
Object Types
glz::object(compile time mixed types)std::mapstd::unordered_mapglz::ordered_small_map(insertion-order, string keys, compact)glz::ordered_map(insertion-order, generic keys, Robin Hood hashing)
See Ordered Maps for detailed comparison and usage.
Variants
std::variant
Variants support auto-deduction and tagged types. Smart pointers (std::unique_ptr, std::shared_ptr) are fully supported as variant alternatives, including with tagged variants.
See Variant Handling for more information.
Nullable Types
std::unique_ptrstd::shared_ptrstd::optional- Raw pointers (
T*)
Nullable types may be allocated by valid input or nullified by the null keyword. Smart pointers can also be used as variant alternatives (e.g., std::variant<std::unique_ptr<A>, std::unique_ptr<B>>), see Variant Handling for details.
Note
Raw pointers work with automatic reflection and respect the skip_null_members option. See Nullable Types for detailed information about pointer handling.
String Types
-
std::string -
std::string_view -
std::filesystem::path- Note that
std::filesystem::pathdoes not work with pure reflection on GCC and MSVC (requires a glz::meta)
- Note that
-
std::bitset
std::bitset<8> b = 0b10101010;
// will be serialized as a string: "10101010"
Chrono Types
std::chrono::duration<Rep, Period>- serializes as numeric countstd::chrono::system_clock::time_point- serializes as ISO 8601 string (JSON) or native datetime (TOML)std::chrono::steady_clock::time_point- serializes as numeric countstd::chrono::high_resolution_clock::time_point- serializes as numeric countstd::chrono::year_month_day- serializes as TOML Local Datestd::chrono::hh_mm_ss<Duration>- serializes as TOML Local Time
See Chrono Support for detailed information about time serialization and epoch_time wrappers.
See TOML Datetime Support for TOML-specific native datetime format.
std::expected
std::expected is supported where the expected value is treated as it would typically be handled in JSON, and the unexpected value is treated as a JSON object with the unexpected value referred to by an "unexpected" key.
Example of unexpected:
{"unexpected": "my error string"}