2

I'm fetching various ontologies from the web and they come in a broad variety of formats. I'd like to use rdflib.js to serialize them to jsonld. The .serialize(target, kb, base, contentType, callback, options) method of rdflib takes several arguments that are not documented and I could not guess them from reading the source at https://linkeddata.github.io/rdflib.js/doc/serialize.js.html

const ont = await fetch('http://xmlns.com/foaf/0.1/');
const jsonlddata = rdflib.serialize(ont, ...?);
Philipp Gfeller
  • 1,167
  • 2
  • 15
  • 36
  • do you want to know how to do it using rdflib.js or do you only want the serialize the ontologies in jsonld ? – Noor Feb 23 '19 at 08:04
  • shouldn't you load the file into a graph `g=rdflib.Graph()` with `g.load('http://xmlns.com/foaf/0.1/')` . And then just something like `g.serialize("PATH_TO_FILE", format='json-ld', indent=4)`? – UninformedUser Feb 23 '19 at 08:19
  • @Noor I'd like to know the most simple way. Performance is secondary in my use case. – Philipp Gfeller Feb 23 '19 at 12:17
  • @AKSW I most likely should do that. If this works, you should post your comment as an answer, so I can accept it (= – Philipp Gfeller Feb 23 '19 at 12:18
  • Funnily enough, a [github issue on the `rdflib.js` project](https://github.com/linkeddata/rdflib.js/issues) is likely to get answers about "arguments that are not documented" and other advice from the developers themselves... – TallTed Feb 25 '19 at 18:45

0 Answers0