What is the JSON-LD API?

I'm sure this has been discussed before, but it only just clicked for
me (dogwalks are good!).

JSON stands for Javascript Object Notation, right?

so if we say

   var object = parse( // bunch of JSON-LD // )

what methods does object support?

Say we've got the description of a book, what about:

   var object = parse( // bunch of JSON-LD // )
   var book = object.book
   var title = book.title

But straight from RDF we're looking at something more like:

   var graph = parse( // bunch of JSON-LD // )

   var rdf_ns = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   var dc_ns = "http://purl.org/dc/elements/1.1/"
   var books_ns = "http://example.org/books#"

   var books = graph.getSubjects(rdf_ns+"type", books_ns+"Book")

   var titles = graphs.getObjects(books[0], rdf_ns+"type")

   var title = titles[0]

I'd say the challenge is to support accessor methods that look more
like the first version above, and less like the second.

But here the thing - ideally want this to work *without* needing a
custom parser.

Looking at it from this point of view, CURIES needn't be a
complication, if we could do things like:

Regular JSON developer version:
   var object = parse( // bunch of JSON-LD // )
   var title = object.book["title"]

RDF person's version:
   var object = parse( // bunch of JSON-LD // )
   var p_title = { "dc", "http://purl.org/dc/elements/1.1/"  }
   var title = object.book[p_title]

So what do the accessor methods of JSON-LD look like today, *without*
a custom parser?

Cheers,
Danny.














-- 
http://dannyayers.com

Received on Wednesday, 31 August 2011 17:35:50 UTC