Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Ā
JSON-LD: Linked Data for Web Apps
1. JSON-LD
Linked Data for Web Apps
Gregg Kellogg
gregg@greggkellogg.net
@gkellogg
Tuesday, July 10, 12
2. Introducing JSON-LD
@graph
@context
@id
JSON-based syntax to express linked data
@language
@value
@list
@type @set
Tuesday, July 10, 12
JSON-LD brings a standard representation for expressing entity-value relationships using a
few standard keywords and a consistent organizational structure for JSON Objects.
ā¢Objects represent entities, with keys acting as properties.
ā¢Properties always expand to full IRIs.
ā¢Arrays express a set of values associated with a property, unordered by default.
ā¢Order expressed in @context or as an expanded value representation.
ā¢Values are Object, string or native, with standard XSD representations for native types.
ā¢Expanded form allows for more datatype and language variations.
3. Self-describing Messages
ā¢ Give objects types {
"@context": {
(@type) "schema": "http://schema.org/",
"Person": "schema:Person",
"knows": {"@id": "schema:knows", "@type": "@id"},
"name": "schema:name",
"image": {"@id": "schema:image", "@type": "@id"},
"url": {"@id": "schema:url", "@type": "@id"}
}
}
{
"@context": "http://example.com/context.jsonld",
"@type": "Person",
"image": "http://localhost:9393/examples/schema.org/janedoe.jpg",
"knows": [
"http://www.xyz.edu/students/alicejones.html",
"http://www.xyz.edu/students/bobsmith.html"
],
"name": "Jane Doe",
"url": "http://www.janedoe.com"
}
Tuesday, July 10, 12
The @type key gives an object with one or more types, described with an IRI.
The @context provides a way to express IRIs as simple terms, and allows values to be typed.
8. History
ā¢ 2010 ā Started as a way to project from the RDFa API
ā¢ Developers want solutions to work within HTML
applications
ā¢ Desire for JSON-idiomatic way of representing RDF
(Linked Data)
ā¢ Adapt existing JSON APIs to Linked Data
Tuesday, July 10, 12
9. History
ā¢ 2011 ā W3C Community Group launched
ā¢ Broad Participation
ā¢ Separation of Syntax from API
ā¢ Proposed to W3C RDF 1.1 Working
Group
Tuesday, July 10, 12
10. History
ā¢ 2012 ā RDF WG abandons other JSON
serialization efforts (RDF/JSON)
ā¢ JSON-LD accepted as ofļ¬cial work item
ā¢ Community Group drafts ļ¬nal report
ā¢ RDF WG to publish JSON-LD (Syntax
and API) as FPWD
Tuesday, July 10, 12
12. ā¢ Make full use of JSON syntactic
{
"@context": "http://json-ld.org/contexts/person",
representations "@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
ā¢ Object deļ¬nes a subject "name": "Gregg Kellogg",
"knows": "http://www.markus-lanthaler.com/"
deļ¬nition }
Tuesday, July 10, 12
13. ā¢ Make full use of JSON syntactic
{
"@context": "http://json-ld.org/contexts/person",
representations "@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
ā¢ Object deļ¬nes a subject "name": "Gregg Kellogg",
"knows": "http://www.markus-lanthaler.com/"
deļ¬nition }
ā¢ Also used for subject
reference and value { "@id": "http://greggkellogg.net/foaf#me" }
representations
Tuesday, July 10, 12
14. ā¢ Make full use of JSON syntactic
{
"@context": "http://json-ld.org/contexts/person",
representations "@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
ā¢ Object deļ¬nes a subject "name": "Gregg Kellogg",
"knows": "http://www.markus-lanthaler.com/"
deļ¬nition }
ā¢ Also used for subject
reference and value { "@id": "http://greggkellogg.net/foaf#me" }
representations
{
"@type": "Recipe",
"name": "Mom's World Famous Banana Bread",
"ingredients": [
ā¢ Arrays describe sets of unordered
values
"3 or 4 ripe bananas, smashed",
"1 egg",
"3/4 cup of sugar"
],
ā¢ Single values can skip array "nutrition": [{
"@type": ["NutritionInformation"],
"calories": ["240 calories"],
"fatContent": ["9 grams fat"]
}]
}
Tuesday, July 10, 12
22. ā¢ More features deļ¬ned in the syntax
speciļ¬cation*:
ā¢ @set, @list, Compact IRIs, Unlabeled
Nodes
ā¢ Embedded @context deļ¬nitions
ā¢ Named Graphs
* http://json-ld.org/spec/latest/json-ld-syntax
Tuesday, July 10, 12
23. Retroļ¬t existing APIs
GET /foaf.json HTTP/1.1
Host: greggkellogg.net
Accept: application/json,*/*;q=0.1
====================================
HTTP/1.0 200 OK
...
Content-Type: application/json
Link: <http://json-ld.org/contexts/person>; rel="describedby"; type="application/ld+json"
{
"name": "Gregg Kellogg",
"homepage": "http://greggkellogg.net/",
"depiction": "http://twitter.com/account/proļ¬le_image/gkellogg"
}
Tuesday, July 10, 12
Normal JSON can be made JSON-LD by adding an external context through an HTTP link
relation.
26. JSON-LD API
ā¢ compact ā use minimal representation
using a supplied @context
ā¢ expand ā expand to full form, removing
embedded @context deļ¬nitions
ā¢ frame ā query for JSON-LD
ā¢ fromRDF/toRDF
Tuesday, July 10, 12
27. More Information
json-ld.org JavaScript
Ruby
w3c Python
PHP
Java
Gregg Kellogg C++
gregg@greggkellogg.net
http://greggkellogg.net/
@gkellogg
Tuesday, July 10, 12