Skip to content

Instantly share code, notes, and snippets.

@bshambaugh
Created March 22, 2017 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bshambaugh/7488b14106fdd2ac4a08f49c47979d46 to your computer and use it in GitHub Desktop.
Save bshambaugh/7488b14106fdd2ac4a08f49c47979d46 to your computer and use it in GitHub Desktop.
A simple example converting jsonld to nquads
var jsonld = require('jsonld');
var doc =
{
"@context": "http://json-ld.org/contexts/person.jsonld",
"@id": "http://dbpedia.org/resource/John_Lennon",
"name": "John Lennon",
"born": "1940-10-09",
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
};
// serialize a document to N-Quads (RDF)
jsonld.toRDF(doc, {format: 'application/nquads'}, function(err, nquads) {
console.log(nquads);
// nquads is a string of nquads
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment