Generic JSON (glz::json_t) Improvements
See Generic JSON documentation for more details.
- dump() for json_t by @stephenberry in #1334
Calling
.dump()on ajson_tvalue is equivalent to callingglz::write_json(value), which returns anexpected<std::string, glz::error_ctx>.
- Support for reading json_t value as the source in #1337
After parsing into a json_t it is sometimes desirable to parse into a concrete struct or a portion of the json_t into a struct. Glaze allows a json_t value to be used as the source where a buffer would normally be passed.
auto json = glz::read_json<glz::json_t>(R"({"foo":"bar"})");
expect(json->contains("foo"));
auto obj = glz::read_json<std::map<std::string, std::string>>(json.value());
// This reads the json_t into a std::mapAnother example:
glz::json_t json{};
expect(not glz::read_json(json, R"("Beautiful beginning")"));
std::string v{};
expect(not glz::read<glz::opts{}>(v, json));
expect(v == "Beautiful beginning");Full Changelog: v3.6.0...v3.6.1