Have you ever noticed how much interlinked JSON data there is on the
Web? While it lacks the controlled vocabularies and uniform linking
mechanism of Linked (RDF) Data, RESTful JSON is a lot like Linked Data
in that it allows a network of well-structured resource descriptions
to be discovered, incrementally, by dereferencing HTTP URIs and
following links in documents. From individual JSON trees, a more
general graph structure emerges. I thought it would be interesting to
apply graph traversal algorithms to this "other" Web data, so I've
added JSON support to Ripple:
http://ripple.fortytwo.net/2010/08/18/json-support-in-ripple/
For example, if you have some JSON that looks like this:
{
"id": 87263474,
"name": "Arthur Dent",
"friends": [
{
"id": 9872282,
"name": "Ford Prefect"
},
{
"id": 1293857,
"name": Zaphod Beeblebrox"
}
],
"age": 34,
"species": {
"name": "human",
"sameas": "http://dbpedia.org/resource/Human"
}
}
...you can traverse through it with the usual Ripple syntax, where the
basic path components are string-valued "keys", e.g.
@define arthur: "[JSON string here]" .
:arthur >> "name" >> .
[1] "Arthur Dent"
:arthur >> "friends" >> each >> "name" >> .
[1] "Ford Prefect"
[2] "Zaphod Beeblebrox"
If you understand the link structure of the JSON, you can traverse to
Arthur's friends, and so on. You can even go crazy with regular
expressions, e.g.
:arthur ("friends" >> each >> "id" >> :derefById >>)* >> "name" >> .
[1] "Arthur Dent"
[2] "Ford Prefect"
[3] "Zaphod Beeblebrox"
[4] "Tricia McMillan"
...
I've slipped a DBpedia URI into the example to show how easily JSON
data could be interlinked with RDF data. For example, this Ripple
expression would give you the name of Arthur Dent's species in German:
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
:arthur >> "species" >> "sameas" >>
rdfs:label >> (lang >> "de" equal >>) require >> .
[1] "Mensch"@de
Check out the blog post for more details.
Best regards,
Josh
--
Joshua Shinavier
Tetherless World Constellation PhD student
http://tw.rpi.edu/wiki/Joshua_Shinavier
http://fortytwo.net
+1 509 570 6990
Cheers,
/peter neubauer
COO and Sales, Neo Technology
GTalk: neubauer.peter
Skype peter.neubauer
Phone +46 704 106975
LinkedIn http://www.linkedin.com/in/neubauer
Twitter http://twitter.com/peterneubauer
http://www.neo4j.org - Your high performance graph database.
http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party.
> I especially like the effortless intermixing of RDF and JSON.
Yes--very cool.
> This is
> something that would be great to have in Gremlin, too. I would call it
> "implicit dataset linking" or something :)
Gremlin does--g:to-json() and g:from-json() allow for the conversion of JSON to and from list/map/primitives.
http://wiki.github.com/tinkerpop/gremlin/gremlin-function-library#utility_functions
And yes---the ability to have a language to "walk" various data structures I think is awesome. With OrientDB implementing both Blueprints graph and object models, I think a next big step for Blueprints is working on the object model (right now it only supports MongoDB and OrientDB). It would be nice to have CouchDB flushed out, TinkerDoc finalized, and killer test suite written. At which point, it will be possible to use Gremlin to walk graphs (property/RDF) and object models (CouchDB, MongoDB, OrientDB, TinkerDoc). Peter: we talked about using Gremlin as a "NoSQL"-language many, many moons ago... Just never got around to making it happen. :( Also---then there are key/value stores, column stores, etc. etc. :) ugh.
Take care,
Marko.
Thanks. Even Semantic Web services which deal with RDF data (e.g. the
new http://www.foaf-search.net/) tend to use JSON for their REST APIs,
so I think it makes sense to provide a unified view over the two data
models.
> This is
> something that would be great to have in Gremlin, too. I would call it
> "implicit dataset linking" or something :)
Yeah, something like that. A Turing-complete path language like
Ripple (or Gremlin) gives you the ability to define "virtual" links
between items not explicitly linked at the data level, so even though
there is no formal relationship between JSON and RDF, you can
construct any number of virtual graphs simply by defining
domain-specific named paths.
Best,
Josh