Hello all,
I am working on a project and wanted to know what is the easiest way to get all the triples out of any given Thing in a generic format using the Inrupt client libraries. If anyone has a recommendation, thanks.
Thanks
Hello all,
I am working on a project and wanted to know what is the easiest way to get all the triples out of any given Thing in a generic format using the Inrupt client libraries. If anyone has a recommendation, thanks.
Thanks
The toRdfJsDataset
function can give you an RDF/JS Dataset containing all Triples in a SolidDataset, which is fairly generic.
If you want just the Triples from a single Thing, you can either create a SolidDataset with just that thing:
const thingSolidDataset = setThing(createSolidDataset, thingToExport);
// You can now call toRdfJsDataset(thingSolidDataset)
or filter the Triples with the Thing’s Subject from the RDF/JS Dataset:
// Assuming you've got the RDF/JS Dataset in rdfJsDataset
const thingTriples = rdfJsDataset.match(new NamedNode(asUrl(thing)), null, null, null);
You’ll also need a library that implements RDF/JS NamedNodes for that last option.