Re: representing deserialized RDF - N3, JSON-LD, RDFa, XML/RDF

> Exactly, I would really like that we can use common way to deal with various RDF constructs in javascript runtime. Statement, IRI, BNode and Literal sound like good candidates to start with :)

If we go for a statement-based representation, we are abandoning the JSON-LD route.
Which is okay if that’s what we want.
If the goal is to exchange data between systems that use triples internally, it probably is what we want.

Here is the representation format I use:

{ subject: 'http://dbpedia.org/resource/Daft_Punk’,
  predicate: 'http://www.w3.org/2000/01/rdf-schema#label',
  object: '"Daft Punk"@en' }

There can possibly be a context field too with a graph URI (or something else).
Blank nodes are just "_:b1", variables are "?a" (if using a Turtle superset).
Also note strings need not be escaped, just wrapped in double quotes.

Advantages:
- plain JavaScript object, so:
  - fast to create and manipulate (especially since they all share the same hidden class) [1]
  - fast to load (no hierarchy traversing, key enumeration or null checking needed)
  - directly serializable as JSON
Disadvantages:
- checking whether the object is a literal is slower [1]

As with any format, you of course need to spend time on converting it to your own,
but this should be quite fast. An alternative is to use a two-field object for `object`
to indicate whether it is a literal or a URI. (But then you get 2 hidden classes at runtime.)

> We could also look at aligning all our test suits to prove that we all can deal with common set of sample data. Possibly taking inspiration from JSON-LD Implementation Report: http://json-ld.org/test-suite/reports/

Good idea, though the test suite can be simple if we like to.
The simpler the format, the simpler the test suite. Also see the Turtle one [2].

Best,

Ruben


[1] https://github.com/RubenVerborgh/TripleRepresentationBenchmark
[2] https://dvcs.w3.org/hg/rdf/raw-file/default/rdf-turtle/reports/index.html

Received on Wednesday, 11 December 2013 10:22:30 UTC