{"id":13424505,"url":"https://github.com/stephenberry/glaze","last_synced_at":"2026-04-08T18:10:55.651Z","repository":{"id":61450578,"uuid":"514251457","full_name":"stephenberry/glaze","owner":"stephenberry","description":"Extremely fast, in memory, JSON and interface library for modern C++","archived":false,"fork":false,"pushed_at":"2025-05-07T20:56:13.000Z","size":7566,"stargazers_count":1835,"open_issues_count":75,"forks_count":160,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-05-12T16:08:19.769Z","etag":null,"topics":["api","beve","binary","cplusplus","cpp","csv","fast","header-only","interface","json","json-rpc2","json-schema","reflection","serialization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stephenberry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-15T11:52:30.000Z","updated_at":"2025-05-12T12:58:12.000Z","dependencies_parsed_at":"2024-01-31T09:06:43.817Z","dependency_job_id":"b687a52d-2f72-4dd5-9014-31390aada47f","html_url":"https://github.com/stephenberry/glaze","commit_stats":{"total_commits":2472,"total_committers":47,"mean_commits":52.59574468085106,"dds":"0.10517799352750812","last_synced_commit":"02aae8292ed05144b0527951336e1b7e1f4735b7"},"previous_names":[],"tags_count":209,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenberry%2Fglaze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenberry%2Fglaze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenberry%2Fglaze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenberry%2Fglaze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenberry","download_url":"https://codeload.github.com/stephenberry/glaze/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253778277,"owners_count":21962839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","beve","binary","cplusplus","cpp","csv","fast","header-only","interface","json","json-rpc2","json-schema","reflection","serialization"],"created_at":"2024-07-31T00:00:55.328Z","updated_at":"2026-04-08T18:10:55.629Z","avatar_url":"https://github.com/stephenberry.png","language":"C++","readme":"# Glaze\nOne of the fastest JSON libraries in the world. Glaze reads and writes from object memory, simplifying interfaces and offering incredible performance.\n\nFormats Supported:\n\n- [JSON](https://stephenberry.github.io/glaze/json/) | `glaze/json.hpp`\n- [BEVE](https://github.com/beve-org/beve) (Binary Efficient Versatile Encoding) | `glaze/beve.hpp`\n- [CBOR](https://stephenberry.github.io/glaze/cbor/) (Concise Binary Object Representation) | `glaze/cbor.hpp`\n- [CSV](https://stephenberry.github.io/glaze/csv/) (Comma Separated Value) | `glaze/csv.hpp`\n- [MessagePack](https://stephenberry.github.io/glaze/msgpack/) | `glaze/msgpack.hpp`\n- [Stencil/Mustache](https://stephenberry.github.io/glaze/stencil-mustache/) (string interpolation) | `glaze/stencil/stencil.hpp`\n- [TOML 1.1](https://stephenberry.github.io/glaze/toml/) (Tom's Obvious, Minimal Language) | `glaze/toml.hpp`\n- [YAML](https://stephenberry.github.io/glaze/yaml/) | `glaze/yaml.hpp`\n- [EETF](https://stephenberry.github.io/glaze/EETF/erlang-external-term-format/) (Erlang External Term Format) | `glaze/eetf.hpp`\n- [And Many More Features](https://stephenberry.github.io/glaze/)\n\n\u003e [!NOTE]\n\u003e\n\u003e Glaze is getting HTTP support with REST servers, clients, websockets, and more. The networking side of Glaze is under active development, and while it is usable and feedback is desired, the API is likely to be changing and improving.\n\n## With C++23 \u0026 C++26 compile time reflection for MSVC, Clang, and GCC!\n\n- Read/write aggregate initializable structs without writing any metadata or macros!\n- See [example on Compiler Explorer](https://gcc.godbolt.org/z/T4To5fKfz)\n\n## C++26 P2996 Reflection Support\n\nGlaze now supports [P2996 \"Reflection for C++26\"](https://wg21.link/P2996). When enabled, P2996 unlocks capabilities that aren't possible with traditional compile-time reflection:\n\n- **Non-aggregate types** — classes with constructors, virtual functions, and inheritance just work\n- **Automatic enum serialization** — no `glz::meta` needed, enums serialize to strings automatically\n- **Unlimited struct members** — no 128-member cap\n- **Private member access** — reflect on all members regardless of access specifiers\n- **Standardized** — no compiler-specific hacks, built on `std::meta`\n\n```cpp\n// Classes with constructors — just works with P2996\nclass User {\npublic:\n   std::string name;\n   int age;\n   User() = default;\n   User(std::string n, int a) : name(std::move(n)), age(a) {}\n};\n\nUser u{\"Alice\", 30};\nauto json = glz::write_json(u).value_or(\"error\");\n// {\"name\":\"Alice\",\"age\":30}\n\n// Enums serialize as strings — no glz::meta required\nenum class Color { Red, Green, Blue };\nColor c = Color::Green;\n\nstruct reflect_enums_opts : glz::opts {\n   bool reflect_enums = true;\n};\nauto color_json = glz::write\u003creflect_enums_opts{}\u003e(c).value_or(\"error\");\n// \"Green\"\n```\n\nSupported compilers: [GCC 16+](https://gcc.gnu.org/gcc-16/changes.html) (`-std=c++26 -freflection`) and [Bloomberg clang-p2996](https://github.com/bloomberg/clang-p2996). See the [P2996 documentation](https://stephenberry.github.io/glaze/p2996-reflection/) for setup and details.\n\n## [📖 Documentation](https://stephenberry.github.io/glaze/)\n\nSee this README, the [Glaze Documentation Page](https://stephenberry.github.io/glaze/), or [docs folder](https://github.com/stephenberry/glaze/tree/main/docs) for documentation.\n\n## Highlights\n\n- Pure, compile time reflection for structs\n  - Powerful meta specialization system for custom names and behavior\n  - [C++26 P2996 reflection](https://stephenberry.github.io/glaze/p2996-reflection/) support — non-aggregates, automatic enums, unlimited members\n- JSON [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259) compliance with UTF-8 validation\n- Standard C++ library support\n- Header only\n- Direct to memory serialization/deserialization\n- Compile time maps with constant time lookups and perfect hashing\n- Powerful wrappers to modify read/write behavior ([Wrappers](https://stephenberry.github.io/glaze/wrappers/))\n- Use your own custom read/write functions ([Custom Read/Write](#custom-readwrite))\n- [Handle unknown keys](https://stephenberry.github.io/glaze/unknown-keys/) in a fast and flexible manner\n- Direct memory access through [JSON pointer syntax](https://stephenberry.github.io/glaze/json-pointer-syntax/)\n- [JMESPath](https://stephenberry.github.io/glaze/JMESPath/) querying\n- No exceptions (compiles with `-fno-exceptions`)\n  - If you desire helpers that throw for cleaner syntax see [Glaze Exceptions](https://stephenberry.github.io/glaze/exceptions/)\n- No runtime type information necessary (compiles with `-fno-rtti`)\n- [JSON Schema generation](https://stephenberry.github.io/glaze/json-schema/)\n- [Partial Read](https://stephenberry.github.io/glaze/partial-read/) and [Partial Write](https://stephenberry.github.io/glaze/partial-write/) support\n- [Streaming I/O](https://stephenberry.github.io/glaze/streaming/) for reading/writing large files with bounded memory\n- [Much more!](#more-features)\n\n## Performance\n\n| Library                                                      | Roundtrip Time (s) | Write (MB/s) | Read (MB/s) |\n| ------------------------------------------------------------ | ------------------ | ------------ | ----------- |\n| [**Glaze**](https://github.com/stephenberry/glaze)           | **1.01**           | **1396**     | **1200**    |\n| [**simdjson (on demand)**](https://github.com/simdjson/simdjson) | **N/A**            | **N/A**      | **1163**    |\n| [**yyjson**](https://github.com/ibireme/yyjson)              | **1.22**           | **1023**     | **1106**    |\n| [**reflect_cpp**](https://github.com/getml/reflect-cpp)      | **3.15**           | **488**      | **365**     |\n| [**daw_json_link**](https://github.com/beached/daw_json_link) | **3.29**           | **334**      | **479**     |\n| [**RapidJSON**](https://github.com/Tencent/rapidjson)        | **3.76**           | **289**      | **416**     |\n| [**json_struct**](https://github.com/jorgen/json_struct)     | **5.87**           | **178**      | **316**     |\n| [**Boost.JSON**](https://boost.org/libs/json)                | **5.38**           | **198**      | **308**     |\n| [**nlohmann**](https://github.com/nlohmann/json)             | **15.44**          | **86**       | **81**      |\n\n[Performance test code available here](https://github.com/stephenberry/json_performance)\n\n*Performance caveats: [simdjson](https://github.com/simdjson/simdjson) and [yyjson](https://github.com/ibireme/yyjson) are great, but they experience major performance losses when the data is not in the expected sequence or any keys are missing (the problem grows as the file size increases, as they must re-iterate through the document).*\n\n*Also, [simdjson](https://github.com/simdjson/simdjson) and [yyjson](https://github.com/ibireme/yyjson) do not support automatic escaped string handling, so if any of the currently non-escaped strings in this benchmark were to contain an escape, the escapes would not be handled.*\n\n[ABC Test](https://github.com/stephenberry/json_performance) shows how simdjson has poor performance when keys are not in the expected sequence:\n\n| Library                                                      | Read (MB/s) |\n| ------------------------------------------------------------ | ----------- |\n| [**Glaze**](https://github.com/stephenberry/glaze)           | **1219**    |\n| [**simdjson (on demand)**](https://github.com/simdjson/simdjson) | **89**      |\n\n## Binary Performance\n\nTagged binary specification: [BEVE](https://github.com/beve-org/beve)\n\n| Metric                | Roundtrip Time (s) | Write (MB/s) | Read (MB/s) |\n| --------------------- | ------------------ | ------------ | ----------- |\n| Raw performance       | **0.42**           | **3235**     | **2468**    |\n| Equivalent JSON data* | **0.42**           | **3547**     | **2706**    |\n\nJSON size: 670 bytes\n\nBEVE size: 611 bytes\n\n*BEVE packs more efficiently than JSON, so transporting the same data is even faster.\n\n## Examples\n\n\u003e [!TIP]\n\u003e\n\u003e See the [example_json](https://github.com/stephenberry/glaze/blob/main/tests/example_json/example_json.cpp) unit test for basic examples of how to use Glaze. See [json_test](https://github.com/stephenberry/glaze/blob/main/tests/json_test/json_test.cpp) for an extensive test of features.\n\nYour struct will automatically get reflected! No metadata is required by the user.\n\n```c++\nstruct my_struct\n{\n  int i = 287;\n  double d = 3.14;\n  std::string hello = \"Hello World\";\n  std::array\u003cuint64_t, 3\u003e arr = { 1, 2, 3 };\n  std::map\u003cstd::string, int\u003e map{{\"one\", 1}, {\"two\", 2}};\n};\n```\n\n**JSON** (prettified)\n\n```json\n{\n   \"i\": 287,\n   \"d\": 3.14,\n   \"hello\": \"Hello World\",\n   \"arr\": [\n      1,\n      2,\n      3\n   ],\n   \"map\": {\n      \"one\": 1,\n      \"two\": 2\n   }\n}\n```\n\n**Write JSON**\n\n```c++\nmy_struct s{};\nstd::string buffer = glz::write_json(s).value_or(\"error\");\n```\n\nor\n\n```c++\nmy_struct s{};\nstd::string buffer{};\nauto ec = glz::write_json(s, buffer);\nif (ec) {\n  // handle error\n}\n```\n\n**Read JSON**\n\n```c++\nstd::string buffer = R\"({\"i\":287,\"d\":3.14,\"hello\":\"Hello World\",\"arr\":[1,2,3],\"map\":{\"one\":1,\"two\":2}})\";\nauto s = glz::read_json\u003cmy_struct\u003e(buffer);\nif (s) // check std::expected\n{\n  s.value(); // s.value() is a my_struct populated from buffer\n}\n```\n\nor\n\n```c++\nstd::string buffer = R\"({\"i\":287,\"d\":3.14,\"hello\":\"Hello World\",\"arr\":[1,2,3],\"map\":{\"one\":1,\"two\":2}})\";\nmy_struct s{};\nauto ec = glz::read_json(s, buffer); // populates s from buffer\nif (ec) {\n  // handle error\n}\n```\n\n### Read/Write From File\n\n```c++\nauto ec = glz::read_file_json(obj, \"./obj.json\", std::string{});\nauto ec = glz::write_file_json(obj, \"./obj.json\", std::string{});\n```\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e The file name (2nd argument), must be null terminated.\n\n### Writing to Streams\n\nFor streaming to `std::ostream` destinations (files, network, etc.) with bounded memory:\n\n```c++\n#include \"glaze/core/ostream_buffer.hpp\"\n\nstd::ofstream file(\"output.json\");\nglz::basic_ostream_buffer\u003cstd::ofstream\u003e buffer(file);  // Concrete type for performance\nauto ec = glz::write_json(obj, buffer);\n```\n\nThe buffer flushes incrementally during serialization, enabling arbitrarily large outputs with fixed memory. See [Streaming I/O](https://stephenberry.github.io/glaze/streaming/) for details on buffer types and stream concepts.\n\n### Reading from Streams\n\nFor streaming from `std::istream` sources (files, network, etc.) with bounded memory:\n\n```c++\n#include \"glaze/core/istream_buffer.hpp\"\n\nstd::ifstream file(\"input.json\");\nglz::basic_istream_buffer\u003cstd::ifstream\u003e buffer(file);\nmy_struct obj;\nauto ec = glz::read_json(obj, buffer);\n```\n\nThe buffer refills automatically during parsing, enabling reading of arbitrarily large inputs with fixed memory. See [Streaming I/O](https://stephenberry.github.io/glaze/streaming/) for NDJSON processing and other streaming patterns.\n\n## Compiler/System Support\n\n- Requires C++23\n- Tested for both 64bit and 32bit\n- Supports both little-endian and big-endian systems\n\n[Actions](https://github.com/stephenberry/glaze/actions) build and test with [Clang](https://clang.llvm.org) (18+), [MSVC](https://visualstudio.microsoft.com/vs/features/cplusplus/) (2022), and [GCC](https://gcc.gnu.org) (13+) on apple, windows, and linux. Big-endian is tested via QEMU emulation on s390x.\n\n![clang build](https://github.com/stephenberry/glaze/actions/workflows/clang.yml/badge.svg) ![gcc build](https://github.com/stephenberry/glaze/actions/workflows/gcc.yml/badge.svg) ![msvc build](https://github.com/stephenberry/glaze/actions/workflows/msvc.yml/badge.svg) \n\n\u003e Glaze seeks to maintain compatibility with the latest three versions of GCC and Clang, as well as the latest version of MSVC and Apple Clang (Xcode). And, we aim to only drop old versions with major releases.\n\n### MSVC Compiler Flags\n\nGlaze requires a C++ standard conformant pre-processor, which requires the `/Zc:preprocessor` flag when building with MSVC.\n\n### SIMD Architecture Detection\n\nGlaze automatically detects the target architecture and enables platform-specific SIMD optimizations using compiler-predefined macros:\n\n| Flag | Detected When | Architecture |\n|------|--------------|--------------|\n| `GLZ_USE_SSE2` | `__x86_64__` or `_M_X64` | x86-64 (always has SSE2) |\n| `GLZ_USE_AVX2` | `__AVX2__` (in addition to x86-64) | x86-64 with AVX2 |\n| `GLZ_USE_NEON` | `__aarch64__`, `_M_ARM64`, or `__ARM_NEON` | ARM64 / AArch64 |\n\nSince these are target-architecture macros set by the compiler, cross-compilation works automatically (e.g., an x86 host cross-compiling for ARM will not enable x86 SIMD paths).\n\nTo disable SIMD optimizations:\n\n```cmake\nset(glaze_DISABLE_SIMD_WHEN_SUPPORTED ON)\n```\n\nThis sets `GLZ_DISABLE_SIMD` as an INTERFACE compile definition, propagated to all targets linking against `glaze::glaze`. Without CMake, define `GLZ_DISABLE_SIMD` before including Glaze headers.\n\n### Disable Forced Inlining\n\nFor faster compilation and reduced binary size at the cost of peak performance, use `glaze_DISABLE_ALWAYS_INLINE`:\n\n```cmake\nset(glaze_DISABLE_ALWAYS_INLINE ON)\n```\n\n\u003e **Note:** This reduces compilation time and binary size, which can be useful for embedded systems where size is critical. For additional binary size reduction, see Optimization Levels below.\n\n### C++26 P2996 Reflection\n\nGlaze supports [C++26 P2996 reflection](https://wg21.link/P2996) as an alternative backend for struct reflection. This replaces traditional `__PRETTY_FUNCTION__` parsing with standardized reflection primitives.\n\n```cmake\nset(glaze_ENABLE_REFLECTION26 ON)\n```\n\nRequires [GCC 16+](https://gcc.gnu.org/gcc-16/changes.html) or [Bloomberg clang-p2996](https://github.com/bloomberg/clang-p2996) with flags:\n\n**GCC 16+:**\n```bash\n-std=c++26 -freflection\n```\n\n**Bloomberg clang-p2996:**\n```bash\n-std=c++26 -freflection -fexpansion-statements -stdlib=libc++\n```\n\nBenefits include unlimited struct members (vs 128 with traditional reflection), cleaner type names, and future C++ standards compliance. See [P2996 Reflection](https://stephenberry.github.io/glaze/p2996-reflection/) for details.\n\n### Optimization Levels (Embedded/Size Optimization)\n\nGlaze provides optimization levels to control the trade-off between binary size and runtime performance. This is useful for embedded systems:\n\n```cpp\nauto json = glz::write\u003cglz::opts_size{}\u003e(obj);\nauto ec = glz::read\u003cglz::opts_size{}\u003e(obj, buffer);\n```\n\n| Level | Preset | Description |\n|-------|--------|-------------|\n| `normal` | (default) | Maximum performance (~278KB lookup tables for integers and floats) |\n| `size` | `opts_size` | Minimal binary (~400B integer tables, `std::to_chars` for floats, linear search) |\n\nSee [Optimization Levels](https://stephenberry.github.io/glaze/optimization-levels/) for full details.\n\n## How To Use Glaze\n\n### [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html)\n```cmake\ninclude(FetchContent)\n\nFetchContent_Declare(\n  glaze\n  GIT_REPOSITORY https://github.com/stephenberry/glaze.git\n  GIT_TAG main\n  GIT_SHALLOW TRUE\n)\n\nFetchContent_MakeAvailable(glaze)\n\ntarget_link_libraries(${PROJECT_NAME} PRIVATE glaze::glaze)\n```\n\n### [Conan](https://conan.io)\n\n- Included in [Conan Center](https://conan.io/center/) ![Conan Center](https://img.shields.io/conan/v/glaze)\n\n```\nfind_package(glaze REQUIRED)\n\ntarget_link_libraries(main PRIVATE glaze::glaze)\n```\n\n### [build2](https://build2.org)\n\n- Available on [cppget](https://cppget.org/libglaze)\n\n```\nimport libs = libglaze%lib{glaze}\n```\n\n### Arch Linux\n\n- [Official Arch repository](https://archlinux.org/packages/extra/any/glaze/)\n- AUR git package: [glaze-git](https://aur.archlinux.org/packages/glaze-git)\n\n### See this [Example Repository](https://github.com/stephenberry/glaze_example) for how to use Glaze in a new project\n\n---\n\n## See [FAQ](https://stephenberry.github.io/glaze/FAQ/) for Frequently Asked Questions\n\n# Explicit Metadata\n\nIf you want to specialize your reflection then you can **optionally** write the code below:\n\n\u003e This metadata is also necessary for non-aggregate initializable structs.\n\n```c++\ntemplate \u003c\u003e\nstruct glz::meta\u003cmy_struct\u003e {\n   using T = my_struct;\n   static constexpr auto value = object(\n      \u0026T::i,\n      \u0026T::d,\n      \u0026T::hello,\n      \u0026T::arr,\n      \u0026T::map\n   );\n};\n```\n\n## Local Glaze Meta\n\n\u003cdetails\u003e\u003csummary\u003eGlaze also supports metadata within its associated class:\u003c/summary\u003e\n\n```c++\nstruct my_struct\n{\n  int i = 287;\n  double d = 3.14;\n  std::string hello = \"Hello World\";\n  std::array\u003cuint64_t, 3\u003e arr = { 1, 2, 3 };\n  std::map\u003cstd::string, int\u003e map{{\"one\", 1}, {\"two\", 2}};\n  \n  struct glaze {\n     using T = my_struct;\n     static constexpr auto value = glz::object(\n        \u0026T::i,\n        \u0026T::d,\n        \u0026T::hello,\n        \u0026T::arr,\n        \u0026T::map\n     );\n  };\n};\n```\n\n\u003c/details\u003e\n\n## Custom Key Names or Unnamed Types\n\nWhen you define Glaze metadata, objects will automatically reflect the non-static names of your member object pointers. However, if you want custom names or you register lambda functions or wrappers that do not provide names for your fields, you can optionally add field names in your metadata.\n\nExample of custom names:\n\n```c++\ntemplate \u003c\u003e\nstruct glz::meta\u003cmy_struct\u003e {\n   using T = my_struct;\n   static constexpr auto value = object(\n      \"integer\", \u0026T::i,\n      \"double\", \u0026T::d,\n      \"string\", \u0026T::hello,\n      \"array\", \u0026T::arr,\n      \"my map\", \u0026T::map\n   );\n};\n```\n\n\u003e Each of these strings is optional and can be removed for individual fields if you want the name to be reflected.\n\u003e\n\u003e Names are required for:\n\u003e\n\u003e - static constexpr member variables\n\u003e - [Wrappers](https://stephenberry.github.io/glaze/wrappers/)\n\u003e - Lambda functions\n\n### Extending pure reflection with `modify`\n\nIf you only need to tweak a couple of fields, you can layer those changes on top of the automatically reflected members with `glz::meta\u003cT\u003e::modify`:\n\n```c++\nstruct server_status\n{\n   std::string name;\n   std::string region;\n   uint64_t active_sessions{};\n   std::optional\u003cstd::string\u003e maintenance;\n   double cpu_percent{};\n};\n\ntemplate \u003c\u003e struct glz::meta\u003cserver_status\u003e\n{\n   static constexpr auto modify = glz::object(\n      \"maintenance_alias\", [](auto\u0026 self) -\u003e auto\u0026 { return self.maintenance; },\n      \"cpuPercent\", \u0026server_status::cpu_percent\n   );\n};\n```\n\nSerialising\n\n```c++\nserver_status status{\n   .name = \"edge-01\",\n   .region = \"us-east\",\n   .active_sessions = 2412,\n   .maintenance = std::string{\"scheduled\"},\n   .cpu_percent = 73.5,\n};\n```\n\nproduces\n\n```json\n{\n  \"name\": \"edge-01\",\n  \"region\": \"us-east\",\n  \"active_sessions\": 2412,\n  \"maintenance\": \"scheduled\",\n  \"cpu_percent\": 73.5,\n  \"maintenance_alias\": \"scheduled\",\n  \"cpuPercent\": 73.5\n}\n```\n\nAll the untouched members (`name`, `region`, `active_sessions`, `maintenance`, `cpu_percent`) still come from pure reflection, so adding or removing members later keeps working automatically. Only the extra keys provided in `modify` are layered on top.\n\n# Reflection API\n\nGlaze provides a compile time reflection API that can be modified via `glz::meta` specializations. This reflection API uses pure reflection unless a `glz::meta` specialization is provided, in which case the default behavior is overridden by the developer.\n\n```c++\nstatic_assert(glz::reflect\u003cmy_struct\u003e::size == 5); // Number of fields\nstatic_assert(glz::reflect\u003cmy_struct\u003e::keys[0] == \"i\"); // Access keys\n```\n\n\u003e [!WARNING]\n\u003e\n\u003e The `glz::reflect` fields described above have been formalized and are unlikely to change. Other fields may evolve as we continue to formalize the spec.\n\n## glz::for_each_field\n\n```c++\nstruct test_type {\n   int32_t int1{};\n   int64_t int2{};\n};\n\ntest_type var{42, 43};\n\nglz::for_each_field(var, [](auto\u0026 field) {\n    field += 1;\n});\n\nexpect(var.int1 == 43);\nexpect(var.int2 == 44);\n```\n\n# Custom Read/Write\n\nCustom reading and writing can be achieved through the powerful `to`/`from` specialization approach, which is described here: [custom-serialization.md](https://github.com/stephenberry/glaze/blob/main/docs/custom-serialization.md). However, this only works for user defined types.\n\nFor common use cases or cases where a specific member variable should have special reading and writing, you can use [glz::custom](https://github.com/stephenberry/glaze/blob/main/docs/wrappers.md#custom) to register read/write member functions, std::functions, or lambda functions.\n\n\u003cdetails\u003e\u003csummary\u003eSee example:\u003c/summary\u003e\n\n```c++\nstruct custom_encoding\n{\n   uint64_t x{};\n   std::string y{};\n   std::array\u003cuint32_t, 3\u003e z{};\n   \n   void read_x(const std::string\u0026 s) {\n      x = std::stoi(s);\n   }\n   \n   uint64_t write_x() {\n      return x;\n   }\n   \n   void read_y(const std::string\u0026 s) {\n      y = \"hello\" + s;\n   }\n   \n   auto\u0026 write_z() {\n      z[0] = 5;\n      return z;\n   }\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003ccustom_encoding\u003e\n{\n   using T = custom_encoding;\n   static constexpr auto value = object(\"x\", custom\u003c\u0026T::read_x, \u0026T::write_x\u003e, //\n                                        \"y\", custom\u003c\u0026T::read_y, \u0026T::y\u003e, //\n                                        \"z\", custom\u003c\u0026T::z, \u0026T::write_z\u003e);\n};\n\nsuite custom_encoding_test = [] {\n   \"custom_reading\"_test = [] {\n      custom_encoding obj{};\n      std::string s = R\"({\"x\":\"3\",\"y\":\"world\",\"z\":[1,2,3]})\";\n      expect(!glz::read_json(obj, s));\n      expect(obj.x == 3);\n      expect(obj.y == \"helloworld\");\n      expect(obj.z == std::array\u003cuint32_t, 3\u003e{1, 2, 3});\n   };\n   \n   \"custom_writing\"_test = [] {\n      custom_encoding obj{};\n      std::string s = R\"({\"x\":\"3\",\"y\":\"world\",\"z\":[1,2,3]})\";\n      expect(!glz::read_json(obj, s));\n      std::string out{};\n      expect(not glz::write_json(obj, out));\n      expect(out == R\"({\"x\":3,\"y\":\"helloworld\",\"z\":[5,2,3]})\");\n   };\n};\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eAnother example with constexpr lambdas:\u003c/summary\u003e\n\n```c++\nstruct custom_buffer_input\n{\n   std::string str{};\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003ccustom_buffer_input\u003e\n{\n   static constexpr auto read_x = [](custom_buffer_input\u0026 s, const std::string\u0026 input) { s.str = input; };\n   static constexpr auto write_x = [](auto\u0026 s) -\u003e auto\u0026 { return s.str; };\n   static constexpr auto value = glz::object(\"str\", glz::custom\u003cread_x, write_x\u003e);\n};\n\nsuite custom_lambdas_test = [] {\n   \"custom_buffer_input\"_test = [] {\n      std::string s = R\"({\"str\":\"Hello!\"})\";\n      custom_buffer_input obj{};\n      expect(!glz::read_json(obj, s));\n      expect(obj.str == \"Hello!\");\n      s.clear();\n      expect(!glz::write_json(obj, s));\n      expect(s == R\"({\"str\":\"Hello!\"})\");\n      expect(obj.str == \"Hello!\");\n   };\n};\n```\n\n\u003c/details\u003e\n\n### Error handling with `glz::custom`\n\nDevelopers can throw errors, but for builds that disable exceptions or if it is desirable to integrate error handling within Glaze's `context`, the last argument of custom lambdas may be a `glz::context\u0026`. This enables custom error handling that integrates well with the rest of Glaze.\n\n\u003cdetails\u003e\u003csummary\u003eSee example:\u003c/summary\u003e\n\n```c++\nstruct age_custom_error_obj\n{\n   int age{};\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cage_custom_error_obj\u003e\n{\n   using T = age_custom_error_obj;\n   static constexpr auto read_x = [](T\u0026 s, int age, glz::context\u0026 ctx) {\n      if (age \u003c 21) {\n         ctx.error = glz::error_code::constraint_violated;\n         ctx.custom_error_message = \"age too young\";\n      }\n      else {\n         s.age = age;\n      }\n   };\n   static constexpr auto value = object(\"age\", glz::custom\u003cread_x, \u0026T::age\u003e);\n};\n```\n\nIn use:\n```c++\nage_custom_error_obj obj{};\nstd::string s = R\"({\"age\":18})\";\nauto ec = glz::read_json(obj, s);\nauto err_msg = glz::format_error(ec, s);\nstd::cout \u003c\u003c err_msg \u003c\u003c '\\n';\n```\n\nConsole output:\n```\n1:10: constraint_violated\n   {\"age\":18}\n            ^ age too young\n```\n\n\u003c/details\u003e\n\n# Object Mapping\n\nWhen using member pointers (e.g. `\u0026T::a`) the C++ class structures must match the JSON interface. It may be desirable to map C++ classes with differing layouts to the same object interface. This is accomplished through registering lambda functions instead of member pointers.\n\n```c++\ntemplate \u003c\u003e\nstruct glz::meta\u003cThing\u003e {\n   static constexpr auto value = object(\n      \"i\", [](auto\u0026\u0026 self) -\u003e auto\u0026 { return self.subclass.i; }\n   );\n};\n```\n\nThe value `self` passed to the lambda function will be a `Thing` object, and the lambda function allows us to make the subclass invisible to the object interface.\n\nLambda functions by default copy returns, therefore the `auto\u0026` return type is typically required in order for glaze to write to memory.\n\n\u003e Note that remapping can also be achieved through pointers/references, as glaze treats values, pointers, and references in the same manner when writing/reading.\n\n# Value Types\n\nA class can be treated as an underlying value as follows:\n\n```c++\nstruct S {\n  int x{};\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cS\u003e {\n  static constexpr auto value{ \u0026S::x };\n};\n```\n\nor using a lambda:\n\n```c++\ntemplate \u003c\u003e\nstruct glz::meta\u003cS\u003e {\n  static constexpr auto value = [](auto\u0026 self) -\u003e auto\u0026 { return self.x; };\n};\n```\n\n# Read Constraints\n\nGlaze provides a wrapper to enable complex reading constraints for struct members: `glz::read_constraint`.\n\n\u003cdetails\u003e\u003csummary\u003eSee example:\u003c/summary\u003e\n\n```c++\nstruct constrained_object\n{\n   int age{};\n   std::string name{};\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cconstrained_object\u003e\n{\n   using T = constrained_object;\n   static constexpr auto limit_age = [](const T\u0026, int age) {\n      return (age \u003e= 0 \u0026\u0026 age \u003c= 120);\n   };\n   \n   static constexpr auto limit_name = [](const T\u0026, const std::string\u0026 name) {\n      return name.size() \u003c= 8;\n   };\n   \n   static constexpr auto value = object(\"age\", read_constraint\u003c\u0026T::age, limit_age, \"Age out of range\"\u003e, //\n                                        \"name\", read_constraint\u003c\u0026T::name, limit_name, \"Name is too long\"\u003e);\n};\n```\n\nFor invalid input such as `{\"age\": -1, \"name\": \"Victor\"}`, Glaze will outut the following formatted error message:\n\n```\n1:11: constraint_violated\n   {\"age\": -1, \"name\": \"Victor\"}\n             ^ Age out of range\n```\n\n- Member functions can also be registered as the constraint. \n- The first field of the constraint lambda is the parent object, allowing complex constraints to be written by the user.\n\n\u003c/details\u003e\n\n# Reading/Writing Private Fields\n\nSerialize and deserialize private fields by making a `glz::meta\u003cT\u003e` and adding `friend struct glz::meta\u003cT\u003e;` to your class.\n\n\u003cdetails\u003e\u003csummary\u003eSee example:\u003c/summary\u003e\n\n```c++\nclass private_fields_t\n{\nprivate:\n   double cash = 22.0;\n   std::string currency = \"$\";\n\n   friend struct glz::meta\u003cprivate_fields_t\u003e;\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cprivate_fields_t\u003e\n{\n   using T = private_fields_t;\n   static constexpr auto value = object(\u0026T::cash, \u0026T::currency);\n};\n\nsuite private_fields_tests = []\n{\n   \"private fields\"_test = [] {\n      private_fields_t obj{};\n      std::string buffer{};\n      expect(not glz::write_json(obj, buffer));\n      expect(buffer == R\"({\"cash\":22,\"currency\":\"$\"})\");\n      \n      buffer = R\"({\"cash\":2200.0, \"currency\":\"¢\"})\";\n      expect(not glz::read_json(obj, buffer));\n      buffer.clear();\n      expect(not glz::write_json(obj, buffer));\n      expect(buffer == R\"({\"cash\":2200,\"currency\":\"¢\"})\");\n   };\n};\n```\n\n\u003c/details\u003e\n\n# Error Handling\n\nGlaze is safe to use with untrusted messages. Errors are returned as error codes, typically within a `glz::expected`, which behaves just like a `std::expected`.\n\n\u003e Glaze works to short circuit error handling, which means the parsing exits very rapidly if an error is encountered.\n\nTo generate more helpful error messages, call `format_error`:\n\n```c++\nauto pe = glz::read_json(obj, buffer);\nif (pe) {\n  std::string descriptive_error = glz::format_error(pe, buffer);\n}\n```\n\nThis test case:\n\n```json\n{\"Hello\":\"World\"x, \"color\": \"red\"}\n```\n\nProduces this error:\n\n```\n1:17: expected_comma\n   {\"Hello\":\"World\"x, \"color\": \"red\"}\n                   ^\n```\n\nDenoting that x is invalid here.\n\n## Bytes Consumed on Read\n\nThe `error_ctx` type returned by read operations includes a `count` field that indicates the byte position in the input buffer:\n\n```c++\nstd::string buffer = R\"({\"x\":1,\"y\":2})\";\nmy_struct obj{};\nauto ec = glz::read_json(obj, buffer);\nif (!ec) {\n   // Success: ec.count contains bytes consumed\n   size_t bytes_consumed = ec.count;\n   // bytes_consumed == 13 (entire JSON object)\n}\n```\n\nThis is useful for:\n- **Streaming**: Reading multiple JSON values from a single buffer\n- **Partial parsing**: Knowing where parsing stopped with `partial_read` option\n- **Error diagnostics**: On failure, `count` indicates where the error occurred\n\n# Input Buffer (Null) Termination\n\nA non-const `std::string` is recommended for input buffers, as this allows Glaze to improve performance with temporary padding and the buffer will be null terminated.\n\n## JSON\n\nBy default the option `null_terminated` is set to `true` and null-terminated buffers must be used when parsing JSON. The option can be turned off with a small loss in performance, which allows non-null terminated buffers:\n\n```c++\nconstexpr glz::opts options{.null_terminated = false};\nauto ec = glz::read\u003coptions\u003e(value, buffer); // read in a non-null terminated buffer\n```\n\n## BEVE\n\nNull-termination is not required for BEVE. It makes no difference in performance.\n\n## CBOR\n\nNull-termination is not required for CBOR. It makes no difference in performance.\n\n## CSV\n\nNull-termination is not required for CSV. It makes no difference in performance.\n\n\n# Type Support\n\n## Array Types\n\nArray types logically convert to JSON array values. Concepts are used to allow various containers and even user containers if they match standard library interfaces.\n\n- `glz::array` (compile time mixed types)\n- `std::tuple` (compile time mixed types)\n- `std::array`\n- `std::vector`\n- `std::deque`\n- `std::list`\n- `std::forward_list`\n- `std::span`\n- `std::set`\n- `std::unordered_set`\n\n## Object Types\n\nObject types logically convert to JSON object values, such as maps. Like JSON, Glaze treats object definitions as unordered maps. Therefore the order of an object layout does not have to match the same binary sequence in C++.\n\n- `glz::object` (compile time mixed types)\n- `std::map`\n- `std::unordered_map`\n- `std::pair` (enables dynamic keys in stack storage)\n\n\u003e `std::pair` is handled as an object with a single key and value, but when `std::pair` is used in an array, Glaze concatenates the pairs into a single object. `std::vector\u003cstd::pair\u003c...\u003e\u003e` will serialize as a single  object. If you don't want this behavior set the compile time option `.concatenate = false`.\n\n## Variants\n\n- `std::variant`\n\nSee [Variant Handling](https://stephenberry.github.io/glaze/variant-handling/) for more information.\n\n## Nullable Types\n\n- `std::unique_ptr`\n- `std::shared_ptr`\n- `std::optional`\n\nNullable types may be allocated by valid input or nullified by the `null` keyword.\n\n```c++\nstd::unique_ptr\u003cint\u003e ptr{};\nstd::string buffer{};\nexpect(not glz::write_json(ptr, buffer));\nexpect(buffer == \"null\");\n\nexpect(not glz::read_json(ptr, \"5\"));\nexpect(*ptr == 5);\nbuffer.clear();\nexpect(not glz::write_json(ptr, buffer));\nexpect(buffer == \"5\");\n\nexpect(not glz::read_json(ptr, \"null\"));\nexpect(!bool(ptr));\n```\n\n## Enums\n\nBy default enums will be written and read in integer form. No `glz::meta` is necessary if this is the desired behavior.\n\nHowever, if you prefer to use enums as strings in JSON, they can be registered in the `glz::meta` as follows:\n\n```c++\nenum class Color { Red, Green, Blue };\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cColor\u003e {\n   using enum Color;\n   static constexpr auto value = enumerate(Red,\n                                           Green,\n                                           Blue\n   );\n};\n```\n\nIn use:\n\n```c++\nColor color = Color::Red;\nstd::string buffer{};\nglz::write_json(color, buffer);\nexpect(buffer == \"\\\"Red\\\"\");\n```\n\n\u003e [!TIP]\n\u003e\n\u003e For automatic enum-to-string serialization without writing metadata for each enum, use an enum reflection library ([magic_enum](https://github.com/Neargye/magic_enum), [enchantum](https://github.com/ZXShady/enchantum), or [simple_enum](https://github.com/arturbac/simple_enum)) with a generic `glz::meta` specialization. See [Automatic Enum Strings](https://stephenberry.github.io/glaze/enum-reflection/) for details.\n\n# JSON With Comments (JSONC)\n\nComments are supported with the specification defined here: [JSONC](https://github.com/stephenberry/JSONC)\n\nRead support for comments is provided with `glz::read_jsonc` or `glz::read\u003cglz::opts{.comments = true}\u003e(...)`.\n\n# Prettify JSON\n\nFormatted JSON can be written out directly via a compile time option:\n\n```c++\nauto ec = glz::write\u003cglz::opts{.prettify = true}\u003e(obj, buffer);\n```\n\nOr, JSON text can be formatted with the `glz::prettify_json` function:\n\n```c++\nstd::string buffer = R\"({\"i\":287,\"d\":3.14,\"hello\":\"Hello World\",\"arr\":[1,2,3]})\");\nauto beautiful = glz::prettify_json(buffer);\n```\n\n`beautiful` is now:\n\n```json\n{\n   \"i\": 287,\n   \"d\": 3.14,\n   \"hello\": \"Hello World\",\n   \"arr\": [\n      1,\n      2,\n      3\n   ]\n}\n```\n\n# Minify JSON\n\nTo write minified JSON:\n\n```c++\nauto ec = glz::write_json(obj, buffer); // default is minified\n```\n\nTo minify JSON text call:\n\n```c++\nstd::string minified = glz::minify_json(buffer);\n```\n\n## Minified JSON Reading\n\nIf you wish require minified JSON or know your input will always be minified, then you can gain a little more performance by using the compile time option `.minified = true`.\n\n```c++\nauto ec = glz::read\u003cglz::opts{.minified = true}\u003e(obj, buffer);\n```\n\n## Boolean Flags\n\nGlaze supports registering a set of boolean flags that behave as an array of string options:\n\n```c++\nstruct flags_t {\n   bool x{ true };\n   bool y{};\n   bool z{ true };\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cflags_t\u003e {\n   using T = flags_t;\n   static constexpr auto value = flags(\"x\", \u0026T::x, \"y\", \u0026T::y, \"z\", \u0026T::z);\n};\n```\n\nExample:\n\n```c++\nflags_t s{};\nexpect(glz::write_json(s) == R\"([\"x\",\"z\"])\");\n```\n\nOnly `\"x\"` and `\"z\"` are written out, because they are true. Reading in the buffer will set the appropriate booleans.\n\n\u003e When writing BEVE, `flags` only use one bit per boolean (byte aligned).\n\n## Logging JSON\n\nSometimes you just want to write out JSON structures on the fly as efficiently as possible. Glaze provides tuple-like structures that allow you to stack allocate structures to write out JSON with high speed. These structures are named `glz::obj` for objects and `glz::arr` for arrays.\n\nBelow is an example of building an object, which also contains an array, and writing it out.\n\n```c++\nauto obj = glz::obj{\"pi\", 3.14, \"happy\", true, \"name\", \"Stephen\", \"arr\", glz::arr{\"Hello\", \"World\", 2}};\n\nstd::string s{};\nexpect(not glz::write_json(obj, s));\nexpect(s == R\"({\"pi\":3.14,\"happy\":true,\"name\":\"Stephen\",\"arr\":[\"Hello\",\"World\",2]})\");\n```\n\n\u003e This approach is significantly faster than `glz::generic` for generic JSON. But, may not be suitable for all contexts.\n\n## Merge\n\n`glz::merge` allows the user to merge multiple JSON object types into a single object.\n\n```c++\nglz::obj o{\"pi\", 3.141};\nstd::map\u003cstd::string_view, int\u003e map = {{\"a\", 1}, {\"b\", 2}, {\"c\", 3}};\nauto merged = glz::merge{o, map};\nstd::string s{};\nglz::write_json(merged, s); // will write out a single, merged object\n// s is now: {\"pi\":3.141,\"a\":0,\"b\":2,\"c\":3}\n```\n\n\u003e `glz::merge` stores references to lvalues to avoid copies\n\n## Generic JSON\n\nSee [Generic JSON](https://stephenberry.github.io/glaze/generic-json/) for `glz::generic`.\n\n```c++\nglz::generic json{};\nstd::string buffer = R\"([5,\"Hello World\",{\"pi\":3.14}])\";\nglz::read_json(json, buffer);\nassert(json[2][\"pi\"].get\u003cdouble\u003e() == 3.14);\n```\n\n## Lazy JSON\n\nSee [Lazy JSON](https://stephenberry.github.io/glaze/lazy-json/) for `glz::lazy_json`.\n\n```c++\nstd::string json = R\"({\"name\":\"John\",\"age\":30,\"city\":\"New York\"})\";\nauto result = glz::lazy_json(json);\nif (result) {\n   auto age = (*result)[\"age\"].get\u003cint\u003e(); // Only parses what you access\n}\n```\n\n\u003e `glz::lazy_json` provides on-demand parsing without any upfront processing, ideal for extracting a few fields from large JSON documents.\n\n`glz::lazy_beve` provides the same lazy parsing capability for BEVE binary format. See [Lazy BEVE](https://stephenberry.github.io/glaze/lazy-beve/).\n\n## Raw Buffer Performance\n\nGlaze is just about as fast writing to a `std::string` as it is writing to a raw char buffer. If you have sufficiently allocated space in your buffer you can write to the raw buffer, as shown below, but it is not recommended.\n\n```c++\nglz::read_json(obj, buffer);\nconst auto result = glz::write_json(obj, buffer.data());\nif (!result) {\n   buffer.resize(result.count);\n}\n```\n\n### Writing to Fixed-Size Buffers\n\nAll write functions return `glz::error_ctx`, which provides both error information and the byte count:\n\n```c++\nstd::array\u003cchar, 1024\u003e buffer;\nauto ec = glz::write_json(my_obj, buffer);\nif (ec) {\n   if (ec.ec == glz::error_code::buffer_overflow) {\n      // Buffer was too small\n      std::cerr \u003c\u003c \"Overflow after \" \u003c\u003c ec.count \u003c\u003c \" bytes\\n\";\n   }\n   return;\n}\n// Success: ec.count contains bytes written\nstd::string_view json(buffer.data(), ec.count);\n```\n\nThe `error_ctx` type provides:\n- `if (ec)` - true when there is an error (matches `std::error_code` semantics)\n- `ec.count` - bytes processed (always populated, even on error)\n- `ec.ec` - the error code\n- `glz::format_error(ec, buffer)` - formatted error message\n\n## Compile Time Options\n\nThe `glz::opts` struct defines the default compile time options for reading/writing.\n\nInstead of calling `glz::read_json(...)`, you can call `glz::read\u003cglz::opts{}\u003e(...)` and customize the options.\n\nFor example: `glz::read\u003cglz::opts{.error_on_unknown_keys = false}\u003e(...)` will turn off erroring on unknown keys and simple skip the items.\n\n`glz::opts` can also switch between formats:\n\n- `glz::read\u003cglz::opts{.format = glz::BEVE}\u003e(...)` -\u003e `glz::read_beve(...)`\n- `glz::read\u003cglz::opts{.format = glz::JSON}\u003e(...)` -\u003e `glz::read_json(...)`\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e See [Options](https://stephenberry.github.io/glaze/options/) for a **comprehensive reference table** of all compile time options, including inheritable options that can be added to custom option structs.\n\n### Common Compile Time Options\n\nThe `glz::opts` struct provides default options. Here are the most commonly used:\n\n| Option | Default | Description |\n|--------|---------|-------------|\n| `format` | `JSON` | Format selector (`JSON`, `BEVE`, `CSV`, `TOML`) |\n| `null_terminated` | `true` | Whether input buffer is null terminated |\n| `error_on_unknown_keys` | `true` | Error on unknown JSON keys |\n| `skip_null_members` | `true` | Skip null values when writing |\n| `prettify` | `false` | Output formatted JSON |\n| `minified` | `false` | Require minified input (faster parsing) |\n| `error_on_missing_keys` | `false` | Require all keys to be present |\n| `partial_read` | `false` | Exit after reading deepest object |\n\n**Inheritable options** (not in `glz::opts` by default) can be added via custom structs:\n\n```c++\nstruct my_opts : glz::opts {\n   bool validate_skipped = true;        // Full validation on skipped values\n   bool append_arrays = true;           // Append to arrays instead of replace\n};\n\nconstexpr my_opts opts{};\nauto ec = glz::read\u003copts\u003e(obj, buffer);\n```\n\n\u003e See [Options](https://stephenberry.github.io/glaze/options/) for the complete list with detailed descriptions, and [Wrappers](https://stephenberry.github.io/glaze/wrappers/) for per-field options.\n\n## JSON Conformance\n\nBy default Glaze is strictly conformant with the latest JSON standard except in two cases with associated options:\n\n- `validate_skipped`\n  This option does full JSON validation for skipped values when parsing. This is not set by default because values are typically skipped when the user is unconcerned with them, and Glaze still validates for major issues. But, this makes skipping faster by not caring if the skipped values are exactly JSON conformant. For example, by default Glaze will ensure skipped numbers have all valid numerical characters, but it will not validate for issues like leading zeros in skipped numbers unless `validate_skipped` is on. Wherever Glaze parses a value to be used it is fully validated.\n- `validate_trailing_whitespace`\n  This option validates the trailing whitespace in a parsed document. Because Glaze parses C++ structs, there is typically no need to continue parsing after the object of interest has been read. Turn on this option if you want to ensure that the rest of the document has valid whitespace, otherwise Glaze will just ignore the content after the content of interest has been parsed.\n\n\u003e [!NOTE]\n\u003e\n\u003e By default, Glaze does not unicode escape control characters (e.g. `\"\\x1f\"` to `\"\\u001f\"`), as this poses a risk of embedding null characters and other invisible characters in strings. The compile time option `escape_control_characters` is available for those who desire to write out control characters as escaped unicode in strings.\n\u003e\n\u003e ```c++\n\u003e // Example options for enabling escape_control_characters\n\u003e struct options : glz::opts {\n\u003e    bool escape_control_characters = true;\n\u003e };\n\u003e ```\n\n## Skip\n\nIt can be useful to acknowledge a keys existence in an object to prevent errors, and yet the value may not be needed or exist in C++. These cases are handled by registering a `glz::skip` type with the meta data.\n\n\u003cdetails\u003e\u003csummary\u003eSee example:\u003c/summary\u003e\n\n```c++\nstruct S {\n  int i{};\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cS\u003e {\n  static constexpr auto value = object(\"key_to_skip\", skip{}, \u0026S::i);\n};\n```\n\n```c++\nstd::string buffer = R\"({\"key_to_skip\": [1,2,3], \"i\": 7})\";\nS s{};\nglz::read_json(s, buffer);\n// The value [1,2,3] will be skipped\nexpect(s.i == 7); // only the value i will be read into\n```\n\n\u003c/details\u003e\n\n## Hide\n\nGlaze is designed to help with building generic APIs. Sometimes a value needs to be exposed to the API, but it is not desirable to read in or write out the value in JSON. This is the use case for `glz::hide`.\n\n`glz::hide` hides the value from JSON output while still allowing API (and JSON pointer) access.\n\n\u003cdetails\u003e\u003csummary\u003eSee example:\u003c/summary\u003e\n\n```c++\nstruct hide_struct {\n  int i = 287;\n  double d = 3.14;\n  std::string hello = \"Hello World\";\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003chide_struct\u003e {\n   using T = hide_struct;\n   static constexpr auto value = object(\u0026T::i,  //\n                                        \u0026T::d, //\n                                        \"hello\", hide{\u0026T::hello});\n};\n```\n\n```c++\nhide_struct s{};\nauto b = glz::write_json(s);\nexpect(b == R\"({\"i\":287,\"d\":3.14})\"); // notice that \"hello\" is hidden from the output\n```\n\n\u003c/details\u003e\n\n## Quoted Numbers\n\nYou can parse quoted JSON numbers directly to types like `double`, `int`, etc. by utilizing the `glz::quoted` wrapper.\n\n```c++\nstruct A {\n   double x;\n   std::vector\u003cuint32_t\u003e y;\n};\n\ntemplate \u003c\u003e\nstruct glz::meta\u003cA\u003e {\n   static constexpr auto value = object(\"x\", glz::quoted_num\u003c\u0026A::x\u003e, \"y\", glz::quoted_num\u003c\u0026A::y\u003e);\n};\n```\n\n```json\n{\n  \"x\": \"3.14\",\n  \"y\": [\"1\", \"2\", \"3\"]\n}\n```\n\nThe quoted JSON numbers will be parsed directly into the `double` and `std::vector\u003cuint32_t\u003e`. The `glz::quoted` function works for nested objects and arrays as well.\n\n## JSON Lines (NDJSON) Support\n\nGlaze supports [JSON Lines](https://jsonlines.org) (or Newline Delimited JSON) for array-like types (e.g. `std::vector` and `std::tuple`).\n\n```c++\nstd::vector\u003cstd::string\u003e x = { \"Hello\", \"World\", \"Ice\", \"Cream\" };\nstd::string s = glz::write_ndjson(x).value_or(\"error\");\nauto ec = glz::read_ndjson(x, s);\n```\n\n# More Features\n\n### [Data Recorder](https://stephenberry.github.io/glaze/recorder/)\n\n### [Command Line Interface Menu](https://stephenberry.github.io/glaze/cli-menu/)\n\n### [JMESPath](https://stephenberry.github.io/glaze/JMESPath/)\n\n- Querying JSON\n\n### [JSON Include System](https://stephenberry.github.io/glaze/json-include/)\n\n### [JSON Pointer Syntax](https://stephenberry.github.io/glaze/json-pointer-syntax/)\n\n### [JSON-RPC 2.0](https://stephenberry.github.io/glaze/rpc/json-rpc/)\n\n### [JSON Schema](https://stephenberry.github.io/glaze/json-schema/)\n\n### [Shared Library API](https://stephenberry.github.io/glaze/glaze-interfaces/)\n\n### [Streaming I/O](https://stephenberry.github.io/glaze/streaming/)\n\n### [Tagged Binary Messages](https://stephenberry.github.io/glaze/binary/)\n\n### [Thread Pool](https://stephenberry.github.io/glaze/thread-pool/)\n\n### [Time Trace Profiling](https://stephenberry.github.io/glaze/time-trace/)\n\n- Output performance profiles to JSON and visualize using [Perfetto](https://ui.perfetto.dev)\n\n### [Wrappers](https://stephenberry.github.io/glaze/wrappers/)\n\n# Extensions\n\nSee the `ext` directory for extensions.\n\n- [Eigen](https://gitlab.com/libeigen/eigen)\n- [JSON-RPC 2.0](https://stephenberry.github.io/glaze/rpc/json-rpc/)\n- [Command Line Interface Menu (cli_menu)](https://stephenberry.github.io/glaze/cli-menu/)\n\n# License\n\nGlaze is distributed under the MIT license with an exception for embedded forms:\n\n\u003e --- Optional exception to the license ---\n\u003e\n\u003e As an exception, if, as a result of your compiling your source code, portions of this Software are embedded into a machine-executable object form of such source code, you may redistribute such embedded portions in such object form without including the copyright and permission notices.\n","funding_links":[],"categories":["CSV","C++","Data Formats","序列化","JSON","File Formats","Program"],"sub_categories":["C/C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenberry%2Fglaze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenberry%2Fglaze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenberry%2Fglaze/lists"}