pub fn json_to_data_url(json: &str) -> IsccResult<String>Expand description
Convert a JSON string into a data: URL with JCS canonicalization.
Parses the JSON, re-serializes to RFC 8785 (JCS)
canonical form, base64-encodes the result, and wraps it in a data: URL.
Uses application/ld+json media type when the JSON contains an @context
key, otherwise application/json.
This enables all language bindings to support dict/object meta parameters by serializing to JSON once (language-specific) then delegating encoding to Rust.
§Errors
Returns IsccError::InvalidInput if json is not valid JSON or if
JCS canonicalization fails.
§Examples
let url = json_to_data_url(r#"{"key": "value"}"#).unwrap();
assert!(url.starts_with("data:application/json;base64,"));
let ld_url = json_to_data_url(r#"{"@context": "https://schema.org"}"#).unwrap();
assert!(ld_url.starts_with("data:application/ld+json;base64,"));