This commit is contained in:
nlohmann committed 2026-10-09 16:09:12 +00:00
1 parent 60e9652b7f
commit 6d3900e253
7 files changed
+8 -77

No files matched your search

+1 -12
View File
@@ -55,18 +55,7 @@ The default values for `BinaryType` is `std::vector<std::uint8_t>`.
When a custom `BinaryType` is configured (other than the default `std::vector<std::uint8_t>`), you can assign values of that type directly to a `basic_json` instance, and they will automatically be recognized as binary values rather than arrays:
```
using custom_json = nlohmann::basic_json<
nlohmann::ordered_map, // ObjectType
std::vector, // ArrayType
std::string, // StringType
bool, // BooleanType
std::int64_t, // NumberIntegerType
std::uint64_t, // NumberUnsignedType
double, // NumberFloatType
std::allocator, // AllocatorType
nlohmann::adl_serializer,
std::vector<std::byte> // Custom BinaryType
>;
using custom_json = nlohmann::ordered_json::with_binary_t<std::vector<std::byte>>;
std::vector<std::byte> data{std::byte{1}, std::byte{2}, std::byte{3}};
custom_json j = data; // Creates a binary value, not an array