diff --git a/src/zarr.v3.cpp b/src/zarr.v3.cpp index d3c060e5..7237147d 100644 --- a/src/zarr.v3.cpp +++ b/src/zarr.v3.cpp @@ -302,7 +302,9 @@ zarr::ZarrV3::write_group_metadata_() const using json = nlohmann::json; json metadata; - metadata["attributes"]["acquire"] = json::parse(external_metadata_json_); + metadata["attributes"]["acquire"] = + external_metadata_json_.empty() ? "" + : json::parse(external_metadata_json_); auto path = (dataset_root_ / "meta" / "root.group.json").string(); common::write_string(path, metadata.dump(4)); diff --git a/tests/write-zarr-v3-raw.cpp b/tests/write-zarr-v3-raw.cpp index b70637a7..047bca80 100644 --- a/tests/write-zarr-v3-raw.cpp +++ b/tests/write-zarr-v3-raw.cpp @@ -98,15 +98,14 @@ setup(AcquireRuntime* runtime) SIZED("ZarrV3"), &props.video[0].storage.identifier)); - const char external_metadata[] = R"({"hello":"world"})"; const struct PixelScale sample_spacing_um = { 1, 1 }; storage_properties_init(&props.video[0].storage.settings, 0, (char*)filename, strlen(filename) + 1, - (char*)external_metadata, - sizeof(external_metadata), + nullptr, + 0, sample_spacing_um); storage_properties_set_chunking_props(&props.video[0].storage.settings, @@ -217,7 +216,7 @@ validate(AcquireRuntime* runtime) f = std::ifstream(metadata_path); metadata = json::parse(f); - CHECK("world" == metadata["attributes"]["acquire"]["hello"]); + CHECK("" == metadata["attributes"]["acquire"]); // check the array metadata file metadata_path = test_path / "meta" / "root" / "0.array.json";