RDFJSON library

The RDFJSON library provides an RDF API with support for manipulating RDF graphs and individual statements. Relies on the RDF/JSON representation internally. Provides both utility functionality for manipulating the RDF/JSON expression directly and an object-oriented layer on top of it for simplified interactions.

Getting started

To get the library you can clone it from bitbucket, e.g.:

git clone

Second, to allow the tests to run and build the library you need to have nodejs, npm and yarn installed.

Third, to be able to build you need require.js and r.js installed, hence you need to run:


Fourth, build the project (strictly speaking you can use the library directly, but it is often a good idea to bring the files together into a layer and optimize the code):

yarn build:browser # or yarn build:node

Node that the above will create a bundle ready to use in the browser or node. The library exposes Graph and Statement classes. For more detail, check the main.js file.

Fifth, to make sure everything works as expected you can run the tests:

cd tests

Using the library

To create a simple graph and add statements you do the following:

var g = new rdfjson.Graph({});
g.addL("", "dcterms:title", "A title");
g.add("", "dcters:relation", "");

Now, to query the graph we use the find method which can have null in one, two or three places:

var stmts = g.find(null, "dcterms:relation", null);
console.log("Found a relation from " + stmts[0].getSubject() + " to " + stmts[0].getValue());

Please check the documentation in Graph.js and Statement.js or for that matter look at the tests. You can also take a look at the samples.