From 398cc2793460d96e366b48ef8d57d620d8a5f3ec Mon Sep 17 00:00:00 2001 From: tmathern <60901087+tmathern@users.noreply.github.com> Date: Mon, 8 Jun 2026 17:02:55 -0700 Subject: [PATCH 1/3] fix: crJson bindings --- compile_commands.json | 1 + include/c2pa.hpp | 8 ++++++++ src/c2pa_reader.cpp | 5 +++++ tests/reader.test.cpp | 24 ++++++++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 120000 compile_commands.json diff --git a/compile_commands.json b/compile_commands.json new file mode 120000 index 00000000..7c1ac711 --- /dev/null +++ b/compile_commands.json @@ -0,0 +1 @@ +build/debug/compile_commands.json \ No newline at end of file diff --git a/include/c2pa.hpp b/include/c2pa.hpp index 53755447..a79576de 100644 --- a/include/c2pa.hpp +++ b/include/c2pa.hpp @@ -935,6 +935,14 @@ namespace c2pa /// @throws C2paException for errors encountered by the C2PA library. std::string detailed_json() const; + /// @brief Get the manifest store as a pretty-printed crJSON string. + /// @details crJSON is a standardized JSON format for C2PA manifest data. + /// This call is infallible at yields valid empty JSON ("{}") if + /// there are no Content Credentials. + /// @return The manifest store as a crJSON string. + /// @throws C2paException if the underlying C call returns null. + std::string crjson() const; + /// @brief Get a resource from the reader and write it to a file. /// @param uri The URI of the resource. /// @param path The file path to write the resource to. diff --git a/src/c2pa_reader.cpp b/src/c2pa_reader.cpp index b47210d5..909e61e7 100644 --- a/src/c2pa_reader.cpp +++ b/src/c2pa_reader.cpp @@ -167,6 +167,11 @@ namespace c2pa return detail::c_string_to_string(c2pa_reader_detailed_json(c2pa_reader)); } + std::string Reader::crjson() const + { + return detail::c_string_to_string(c2pa_reader_crjson(c2pa_reader)); + } + [[nodiscard]] std::optional Reader::remote_url() const { auto url = c2pa_reader_remote_url(c2pa_reader); if (url == nullptr) { return std::nullopt; } diff --git a/tests/reader.test.cpp b/tests/reader.test.cpp index 8c56bce8..68827ee4 100644 --- a/tests/reader.test.cpp +++ b/tests/reader.test.cpp @@ -694,3 +694,27 @@ TEST_F(ReaderTest, ReadArchive) EXPECT_TRUE(active_manifest.contains("ingredients")); EXPECT_EQ(active_manifest["ingredients"].size(), 2); } + +TEST_F(ReaderTest, ReadCrJson) +{ + fs::path current_dir = fs::path(__FILE__).parent_path(); + fs::path test_file = current_dir / "../tests/fixtures/cloud.jpg"; + + auto reader = c2pa::Reader(test_file); + auto crjson = reader.crjson(); + EXPECT_FALSE(crjson.empty()); +} + +TEST_F(ReaderTest, ReadCrJsonSpecialChars) +{ + auto current_dir = fs::path(__FILE__).parent_path(); + #ifdef _WIN32 + auto test_file = current_dir.parent_path() / "tests" / "fixtures" / L"CÖÄ_.jpg"; + #else + auto test_file = current_dir.parent_path() / "tests" / "fixtures" / "CÖÄ_.jpg"; + #endif + + auto reader = c2pa::Reader(test_file); + auto crjson = reader.crjson(); + EXPECT_FALSE(crjson.empty()); +} From 0b127c5bd101e67f189ee4bb9ca6cd2c7f176fe2 Mon Sep 17 00:00:00 2001 From: tmathern <60901087+tmathern@users.noreply.github.com> Date: Mon, 8 Jun 2026 17:06:07 -0700 Subject: [PATCH 2/3] fix: Clean up debug --- compile_commands.json | 1 - 1 file changed, 1 deletion(-) delete mode 120000 compile_commands.json diff --git a/compile_commands.json b/compile_commands.json deleted file mode 120000 index 7c1ac711..00000000 --- a/compile_commands.json +++ /dev/null @@ -1 +0,0 @@ -build/debug/compile_commands.json \ No newline at end of file From 77ccd34dbf70e13c16fcfa590fd2504379496bf1 Mon Sep 17 00:00:00 2001 From: tmathern <60901087+tmathern@users.noreply.github.com> Date: Mon, 8 Jun 2026 17:06:43 -0700 Subject: [PATCH 3/3] Bump project version to 0.23.15 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d0bb390..59e9ab38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.27) # This is the current version of this C++ project -project(c2pa-c VERSION 0.23.14) +project(c2pa-c VERSION 0.23.15) # Set the version of the c2pa_rs library used set(C2PA_VERSION "0.86.1")