Skip to content

v0.6.0 release

Latest

Choose a tag to compare

@homer6 homer6 released this 19 Feb 06:01

automerge-cpp v0.6.0 — Full JSON Ecosystem & Logic Refinement

This release completes the extensive nlohmann/json integration (Phases 12B–12G), making Automerge documents first-class citizens in the JSON ecosystem. It also introduces critical stability fixes for type conversions and pointer-based navigation.


Complete nlohmann/json Integration

Automerge documents now support the full suite of JSON standards for path-based access and batch manipulation.

JSON Pointer, Patch, & Merge Patch

  • JSON Pointer (RFC 6901): Deeply address any value using string paths (e.g., /users/0/name). Includes full support for ~0 and ~1 escaping.

  • am::json::get_pointer, am::json::put_pointer, am::json::delete_pointer.

  • JSON Patch (RFC 6902): Apply atomic batches of add, remove, replace, move, copy, and test operations.

  • am::json::apply_json_patch and am::json::diff_json_patch.

  • JSON Merge Patch (RFC 7386): Update documents using simple "null-means-delete" semantics, perfect for partial state synchronization.

  • am::json::apply_merge_patch and am::json::generate_merge_patch.

Lossless Import & Export

  • Recursive Export: am::json::export_json now fully resolves nested ObjIds, materializing complex Automerge trees into standard JSON objects and arrays.
  • Flatten/Unflatten: Convert nested documents into flat maps of pointer_path -> value for easier debugging or structured configuration management.

Namespace & API Refactoring

To ensure long-term maintainability and prevent name collisions, the JSON API has been structured into two distinct layers:

  1. namespace automerge_cpp (am::): Contains only ADL-based to_json and from_json overloads. This is required for C++ Argument-Dependent Lookup to find converters automatically when writing json j = my_value;.
  2. namespace automerge_cpp::json (am::json::): Contains all explicit interop functions (Import, Export, Pointer, Patch).

Critical Fixes & Stability

Core Logic Improvements

  • Uninitialized Index Fix: Resolved a critical bug in add_value_at_pointer where an uninitialized std::size_t variable could lead to non-deterministic list insertion points.
  • Loop Variable Overflow: Fixed a potential crash in Base64 decoding where an unsigned char loop variable was too narrow for the character lookup table.
  • Recursive Deadlock Prevention: Fixed a "Resource deadlock avoided" error. All JSON write functions now use internal Transaction read methods that bypass shared_mutex acquisition when already inside a transaction.

Serializer Fidelity

  • Unsigned Integer ADL: Reordered type inference in from_json to correctly distinguish between uint64 and int64 based on value range, ensuring larger-than-int64 values are not truncated.

Release Statistics

  • Version: 0.6.0
  • Tests: 583 passing tests (an increase of 98 tests covering RFC compliance and edge cases).
  • New Documentation: Added the JSON Integration Guide covering all new features with usage examples.