3
Most read
4
Most read
5
Most read
JSON-LD
JSON for the Social Web
Gregg Kellogg
gregg@greggkellogg.net
@gkellogg
Wednesday, August 7, 13
Introducing JSON-LD
JSON-based syntax to express linked data
@context
@id
@type
@value
@language
@graph
@list
@set
Wednesday, August 7, 13
{
"@context": "http://json-ld.org/contexts/person",
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": "http://www.markus-lanthaler.com/"
}
•Make full use of JSON syntactic
representations
• Object defines a node definition
Language Principles
• Define referenced node
definition with chaining
{
"@context": "http://json-ld.org/contexts/person",
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": {
"@id": "http://www.markus-lanthaler.com/",
"@type": "Person",
"name": "Markus Lanthaler",
"knows" "http://greggkellogg.net/foaf#me"
}
}
Wednesday, August 7, 13
{
"@id": "http://greggkellogg.net/foaf#me",
"@type": "http://schema.org/Person",
"http://schema.org/name": "Gregg Kellogg",
"http://schema.org/knows": {
"@id": "http://www.markus-lanthaler.com/"
}
}
• Define terms to use short
property names
• Associate types for property
values
{
"@context": "http://json-ld.org/contexts/person",
"id": "http://greggkellogg.net/foaf#me",
"type": "Person",
"name": "Gregg Kellogg",
"knows": "http://www.markus-lanthaler.com/"
}
{
"@context": {
"@vocab": "http://schema.org/",
"knows”: {"@type": "@id"},
"id”: "@id",
"type”: "@type"
}
}
Language Principles
Wednesday, August 7, 13
• Define referenced node
definition with chaining
{
"@context": "http://json-ld.org/contexts/person",
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": {
"@id": "http://www.markus-lanthaler.com/",
"@type": "Person",
"name": "Markus Lanthaler",
"knows" "http://greggkellogg.net/foaf#me"
}
}
{
"@context": "http://json-ld.org/contexts/person",
"@graph": [{
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": "http://www.markus-lanthaler.com/"
}, {
"@id": "http://www.markus-lanthaler.com/",
"@type": "Person",
"name": "Markus Lanthaler",
"knows" "http://greggkellogg.net/foaf#me"
}]
}
Wednesday, August 7, 13
• More features defined in the syntax
specification*:
• Ordered Lists, Compact IRIs, Unlabeled
Nodes, Reverse Properties, Language
Maps, Data Indexing
• Embedded @context definitions
• Datasets/Named Graphs
* http://www.w3.org/TR/json-ld/
Language Principles
Wednesday, August 7, 13
It’s just JSON
{
	
  	
  "verb":	
  "post",
	
  	
  "published":	
  "2011-­‐02-­‐10T15:04:55Z",
	
  	
  "language":	
  "en",
	
  	
  "actor":	
  {
	
  	
  	
  	
  "objectType":	
  "person",
	
  	
  	
  	
  "id":	
  "urn:example:person:marCn",
	
  	
  	
  	
  "displayName":	
  "MarCn	
  Smith",
	
  	
  	
  	
  "url":	
  "hGp://example.org/marCn",
	
  	
  	
  	
  "image":	
  {
	
  	
  	
  	
  	
  	
  "url":	
  "hGp://example.org/marCn/image.jpg",
	
  	
  	
  	
  	
  	
  "mediaType":	
  "image/jpeg",
	
  	
  	
  	
  	
  	
  "width":	
  250,
	
  	
  	
  	
  	
  	
  "height":	
  250
	
  	
  	
  	
  }
	
  	
  },
	
  	
  "object"	
  :	
  {
	
  	
  	
  	
  "objectType":	
  "arCcle",
	
  	
  	
  	
  "id":	
  "urn:example:blog:abc123/xyz",
	
  	
  	
  	
  "url":	
  "hGp://example.org/blog/2011/02/entry",
	
  	
  	
  	
  "displayName":	
  "Why	
  I	
  love	
  AcCvity	
  Streams"
	
  	
  },
	
  	
  "target"	
  :	
  {
	
  	
  	
  	
  "objectType":	
  "blog",
	
  	
  	
  	
  "id":	
  "urn:example:blog:abc123",
	
  	
  	
  	
  "displayName":	
  "MarCn's	
  Blog",
	
  	
  	
  	
  "url":	
  "hGp://example.org/blog/"
	
  	
  }
}
• Express structured data
using regular JSON
idioms.
• Use external @context
to alias terms and cast
types
Wednesday, August 7, 13
RDF 
{
"@context": "http://json-ld.org/contexts/person",
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": {
"@id": "http://www.markus-lanthaler.com/",
"@type": "Person",
"name": "Markus Lanthaler",
"knows" "http://greggkellogg.net/foaf#me"
}
}
Wednesday, August 7, 13
RDF 
{
"@context": "http://json-ld.org/contexts/person",
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": {
"@id": "http://www.markus-lanthaler.com/",
"@type": "Person",
"name": "Markus Lanthaler",
"knows" "http://greggkellogg.net/foaf#me"
}
}
Wednesday, August 7, 13
RDF 
{
"@context": "http://json-ld.org/contexts/person",
"@id": "http://greggkellogg.net/foaf#me",
"@type": "Person",
"name": "Gregg Kellogg",
"knows": {
"@id": "http://www.markus-lanthaler.com/",
"@type": "Person",
"name": "Markus Lanthaler",
"knows" "http://greggkellogg.net/foaf#me"
}
}
@prefix: schema <http://schema.org/> .
<http://greggkellogg.net/foaf#me> a schema:Person;
schema:name “Gregg Kellogg”;
shema:knows <http://www.markus-lanthaler.com/> .
<http://www.markus-lanthaler.com/> a schema:Person
schema:name “Markus Lanthaler”
schema:knows <http://greggkellogg.net/foaf#me> .
Wednesday, August 7, 13
More Information
json-ld.org
w3c
JavaScript
Ruby
Python
Java
PHP
Gregg Kellogg
@gkellogg
gregg@greggkellogg.net
http://greggkellogg.net/
http://www.slideshare.net/gkellogg1/open-social2013
Wednesday, August 7, 13

JSON-LD: JSON for the Social Web

  • 1.
    JSON-LD JSON for theSocial Web Gregg Kellogg [email protected] @gkellogg Wednesday, August 7, 13
  • 2.
    Introducing JSON-LD JSON-based syntaxto express linked data @context @id @type @value @language @graph @list @set Wednesday, August 7, 13
  • 3.
    { "@context": "http://json-ld.org/contexts/person", "@id": "http://greggkellogg.net/foaf#me", "@type":"Person", "name": "Gregg Kellogg", "knows": "http://www.markus-lanthaler.com/" } •Make full use of JSON syntactic representations • Object defines a node definition Language Principles • Define referenced node definition with chaining { "@context": "http://json-ld.org/contexts/person", "@id": "http://greggkellogg.net/foaf#me", "@type": "Person", "name": "Gregg Kellogg", "knows": { "@id": "http://www.markus-lanthaler.com/", "@type": "Person", "name": "Markus Lanthaler", "knows" "http://greggkellogg.net/foaf#me" } } Wednesday, August 7, 13
  • 4.
    { "@id": "http://greggkellogg.net/foaf#me", "@type": "http://schema.org/Person", "http://schema.org/name":"Gregg Kellogg", "http://schema.org/knows": { "@id": "http://www.markus-lanthaler.com/" } } • Define terms to use short property names • Associate types for property values { "@context": "http://json-ld.org/contexts/person", "id": "http://greggkellogg.net/foaf#me", "type": "Person", "name": "Gregg Kellogg", "knows": "http://www.markus-lanthaler.com/" } { "@context": { "@vocab": "http://schema.org/", "knows”: {"@type": "@id"}, "id”: "@id", "type”: "@type" } } Language Principles Wednesday, August 7, 13
  • 5.
    • Define referencednode definition with chaining { "@context": "http://json-ld.org/contexts/person", "@id": "http://greggkellogg.net/foaf#me", "@type": "Person", "name": "Gregg Kellogg", "knows": { "@id": "http://www.markus-lanthaler.com/", "@type": "Person", "name": "Markus Lanthaler", "knows" "http://greggkellogg.net/foaf#me" } } { "@context": "http://json-ld.org/contexts/person", "@graph": [{ "@id": "http://greggkellogg.net/foaf#me", "@type": "Person", "name": "Gregg Kellogg", "knows": "http://www.markus-lanthaler.com/" }, { "@id": "http://www.markus-lanthaler.com/", "@type": "Person", "name": "Markus Lanthaler", "knows" "http://greggkellogg.net/foaf#me" }] } Wednesday, August 7, 13
  • 6.
    • More featuresdefined in the syntax specification*: • Ordered Lists, Compact IRIs, Unlabeled Nodes, Reverse Properties, Language Maps, Data Indexing • Embedded @context definitions • Datasets/Named Graphs * http://www.w3.org/TR/json-ld/ Language Principles Wednesday, August 7, 13
  • 7.
    It’s just JSON {    "verb":  "post",    "published":  "2011-­‐02-­‐10T15:04:55Z",    "language":  "en",    "actor":  {        "objectType":  "person",        "id":  "urn:example:person:marCn",        "displayName":  "MarCn  Smith",        "url":  "hGp://example.org/marCn",        "image":  {            "url":  "hGp://example.org/marCn/image.jpg",            "mediaType":  "image/jpeg",            "width":  250,            "height":  250        }    },    "object"  :  {        "objectType":  "arCcle",        "id":  "urn:example:blog:abc123/xyz",        "url":  "hGp://example.org/blog/2011/02/entry",        "displayName":  "Why  I  love  AcCvity  Streams"    },    "target"  :  {        "objectType":  "blog",        "id":  "urn:example:blog:abc123",        "displayName":  "MarCn's  Blog",        "url":  "hGp://example.org/blog/"    } } • Express structured data using regular JSON idioms. • Use external @context to alias terms and cast types Wednesday, August 7, 13
  • 8.
    RDF  { "@context": "http://json-ld.org/contexts/person", "@id":"http://greggkellogg.net/foaf#me", "@type": "Person", "name": "Gregg Kellogg", "knows": { "@id": "http://www.markus-lanthaler.com/", "@type": "Person", "name": "Markus Lanthaler", "knows" "http://greggkellogg.net/foaf#me" } } Wednesday, August 7, 13
  • 9.
    RDF  { "@context": "http://json-ld.org/contexts/person", "@id":"http://greggkellogg.net/foaf#me", "@type": "Person", "name": "Gregg Kellogg", "knows": { "@id": "http://www.markus-lanthaler.com/", "@type": "Person", "name": "Markus Lanthaler", "knows" "http://greggkellogg.net/foaf#me" } } Wednesday, August 7, 13
  • 10.
    RDF  { "@context": "http://json-ld.org/contexts/person", "@id":"http://greggkellogg.net/foaf#me", "@type": "Person", "name": "Gregg Kellogg", "knows": { "@id": "http://www.markus-lanthaler.com/", "@type": "Person", "name": "Markus Lanthaler", "knows" "http://greggkellogg.net/foaf#me" } } @prefix: schema <http://schema.org/> . <http://greggkellogg.net/foaf#me> a schema:Person; schema:name “Gregg Kellogg”; shema:knows <http://www.markus-lanthaler.com/> . <http://www.markus-lanthaler.com/> a schema:Person schema:name “Markus Lanthaler” schema:knows <http://greggkellogg.net/foaf#me> . Wednesday, August 7, 13
  • 11.

Editor's Notes

  • #3 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.
  • #6 Subject reference identifies an object with @id in the same document, or references an external document (Linked Data).
  • #9 Full transformation from and to the RDF data model as a normative part of the API.