Skip to content

v3.6.1

Compare
Choose a tag to compare
@stephenberry stephenberry released this 30 Sep 19:22
· 303 commits to main since this release

Generic JSON (glz::json_t) Improvements

See Generic JSON documentation for more details.

Calling .dump() on a json_t value is equivalent to calling glz::write_json(value), which returns an expected<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::map

Another 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