Skip to content
Open
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
13 changes: 13 additions & 0 deletions c2pa_c_ffi/src/c_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ pub unsafe extern "C" fn c2pa_reader_json(reader_ptr: *mut C2paReader) -> *mut c
to_c_string(c2pa_reader.json())
}

#[no_mangle]
pub unsafe extern "C" fn c2pa_reader_detailed_json(reader_ptr: *mut C2paReader) -> *mut c_char {
check_or_return_null!(reader_ptr);
let c2pa_reader = guard_boxed!(reader_ptr);

to_c_string(c2pa_reader.detailed_json())
}

/// Returns the remote url of the manifest if it was obtained remotely.
///
/// # Parameters
Expand Down Expand Up @@ -1613,6 +1621,11 @@ mod tests {
.to_str()
.unwrap()
.contains("cawg.ica.credential_valid"));

let json = unsafe { c2pa_reader_detailed_json(reader) };
assert!(!json.is_null());
let json_str = unsafe { CString::from_raw(json) };
println!("json: {}", json_str.to_str().unwrap());
TestC2paStream::drop_c_stream(stream);
}

Expand Down
8 changes: 8 additions & 0 deletions sdk/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ impl Reader {
}
}

/// Get the Reader as a detailed JSON string
pub fn detailed_json(&self) -> String {
match self.to_json_detailed_formatted() {
Ok(value) => serde_json::to_string_pretty(&value).unwrap_or_default(),
Err(_) => "{}".to_string(),
}
}

/// Returns the remote url of the manifest if this [`Reader`] obtained the manifest remotely.
pub fn remote_url(&self) -> Option<&str> {
self.store.remote_url()
Expand Down