Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 8 additions & 0 deletions include/c2pa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions src/c2pa_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> Reader::remote_url() const {
auto url = c2pa_reader_remote_url(c2pa_reader);
if (url == nullptr) { return std::nullopt; }
Expand Down
24 changes: 24 additions & 0 deletions tests/reader.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Loading