github stephenberry/glaze v2.8.0

latest releases: v9.0.0, v8.4.0, v8.3.0...
2 years ago

Major breaking change: Write error handling

The API to write calls in Glaze has been updated to match the read API. So, calls to functions like glz::write_json now return either an error code or an expected.

glz::error_ctx ec = glz::write_json(obj, buffer);
or
glz::expected<std::string, glz::error_ctx> result = glz::write_json(obj);

glz::error_ctx now takes the place of the previous glz::parse_error and glz::write_error. Both read and write APIs return the same glz::error_ctx, which is the same as the previous glz::parse_error.

Important

If you don't compile with errors as warnings, this change in most cases is not breaking. And, for most uses of writing in Glaze there are actually no error conditions that can be triggered during serialization. However, this support is needed for corner cases where write errors could occur, such as when implementing custom serializers.

This change makes Glaze more robust and allows it to advance further as a mixed format serialization library.

Tip

If you don't want to deal with the expected result, write std::string result = glz::write_json(obj).value_or("error");. This will produce invalid JSON. Or, simply return an empty string on error and check if the result is empty.

Full Changelog: v2.7.1...v2.8.0

Don't miss a new glaze release

NewReleases is sending notifications on new releases.