-
Hi there, thank you for your work on this project. It is super exciting. I was wondering if there is any way to do shacl validation against jsonld in this library. I am working on a project that crawls a very large amount of json-ld documents and I was curious if I could validate these directly without needing to convert them to a different format. From what I see in the codebase, the rdf enum does not list jsonld. Lines 8 to 16 in 16e7a0b If this is not possible directly with json-ld, I was curious what intermediate format would be optimal if I do end up converting the json-ld to another format in order to validate it and what Rust library would be best for that. (I may be missing it, but I didn't see a converter for json-ld to triples / quads in this repo) Thank you very much |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
I ended up just converting the jsonld to triples in my client library which is in go, and then using a function like this pub fn validate_triples(
shacl: &str,
triples: &str,
) -> Result<ValidationReport, ValidateError> {
if shacl == "" || triples == "" {
return Err(ValidateError::TargetNodeBlankNode);
}
let schema = ShaclDataManager::load(Cursor::new(shacl), RDFFormat::Turtle, None)?;
let srdf_graph = SRDFGraph::from_str(
triples,
&RDFFormat::Turtle,
None,
&srdf::ReaderMode::default(),
)?;
let data = RdfData::from_graph(srdf_graph)?;
let graph = Graph::from_data(data);
let endpoint_validation = GraphValidation::from_graph(graph, ShaclValidationMode::Native);
let report = endpoint_validation.validate(&schema)?;
Ok(report)
} Would love to get any clarity if there is a better way to do this though. |
Beta Was this translation helpful? Give feedback.
-
Thanks for opening this discussion. Definitely, adding suppport for JSON-LD is in the scope of rudof and we will try to implement it. Your approach of converting JSON-LD to triples is of course valid, but we will try to add native support for JSON-LD in rudof, where in principle we will follow a similar approach, i.e. convert JSON-LD to RDF and validating the resulting RDF. In order to convert JSON-LD to RDF, we will need to review which libraries exist in Rust so we can just leverage on one of those libraries for the conversion. Last time I checked, I found these candidates: |
Beta Was this translation helpful? Give feedback.
-
I have created issue #295 to track support for JSON-LD in rudof. |
Beta Was this translation helpful? Give feedback.
Thanks for opening this discussion. Definitely, adding suppport for JSON-LD is in the scope of rudof and we will try to implement it.
Your approach of converting JSON-LD to triples is of course valid, but we will try to add native support for JSON-LD in rudof, where in principle we will follow a similar approach, i.e. convert JSON-LD to RDF and validating the resulting RDF.
In order to convert JSON-LD to RDF, we will need to review which libraries exist in Rust so we can just leverage on one of those libraries for the conversion.
Last time I checked, I found these candidates: