Slide 1

Slide 1 text

Building Meaningful APIs with JSON-LD

Slide 2

Slide 2 text

Hi • aka BigBlueHat • Strategic Architect at John Wiley & Sons, Inc. • Co-Organizer of REST Fest • Co-Editor of the W3C Web Annotation Data Model & Vocabulary • Co-Chair of the W3C JSON-LD Working Group • Contributor to the W3C Web Publishing Working Group • Core Committer to Apache Annotator & Apache CouchDB

Slide 3

Slide 3 text

Information Management a very brief history…of why I care

Slide 4

Slide 4 text

Vannevar Bush

Slide 5

Slide 5 text

Memex – circa 1945 • “We seem to be worse off than before — for we can enormously extend the record; yet even in its present bulk we can hardly consult it.” • “One cannot hope thus to equal the speed and flexibility with which the mind follows an associative trail, but it should be possible to beat the mind decisively in regard to the permanence and clarity of the items resurrected from storage.” • Wholly new forms of encyclopedias will appear, ready made with a mesh of associative trails running through them, ready to be dropped into the memex and there amplified.

Slide 6

Slide 6 text

The Mechanical Encyclopedia Invented by Angela Ruiz Robles in 1949 A “read only” memex

Slide 7

Slide 7 text

Sir Tim Berners-Lee

Slide 8

Slide 8 text

Information Management: a proposal circa 1989

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Four rules of Linked Data • Use URIs as names for things. • Use HTTP URIs so that people can look up those names. • When someone looks up a URI, provide useful information, using the standard formats. • Include links to other URIs so that they can discover more things.

Slide 11

Slide 11 text

Linked Data image from lod-cloud.net

Slide 12

Slide 12 text

Making Meaningful Data

Slide 13

Slide 13 text

json-ld.org

Slide 14

Slide 14 text

Typical JSON document { "name": "John Lennon", "born": "1940-10-09", "spouse": “Cynthia Lennon" } • Computer sees strings • English speakers can guess meaning from keys and values • Non-English speakers have no route to documentation • Document has no identity • Document has no connection to other documents

Slide 15

Slide 15 text

How about Hypermedia { "name": "John Lennon", "born": "1940-10-09", "spouse": "Cynthia Lennon", "_links": { "self": "http://example.com/john_lennon", "next": "http://example.com/ringo", "up": "http://example.com/the_beetles" } • Computer still sees strings • English speakers can guess meaning from keys and values • Non-English speakers have no route to documentation • Document does have identity • Document does have connection to other documents

Slide 16

Slide 16 text

Adding Meaning with JSON-LD { "@context": "https://json-ld.org/contexts/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "name": "John Lennon", "born": "1940-10-09", "spouse": "http://dbpedia.org/resource/Cynthia_Lennon“ } • Computer sees strings, URLs, and a date • English speakers can get URLs for every term (probably) with documentation • Non-English speakers may discover documentation in their language • Document has clear identity • Document connects to other documents

Slide 17

Slide 17 text

By Our Powers Combined! { "@context": "https://json-ld.org/contexts/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "name": "John Lennon", "born": "1940-10-09", "spouse": "http://dbpedia.org/resource/Cynthia_Lennon", "_links": { "self": "http://dbpedia.org/resource/John_Lennon" } } • Adds hypermedia affordances for UX and bots looking to browse around collections • More specifications exist (Hydra, Web of Things) that expand on this possibility

Slide 18

Slide 18 text

Let’s look at how Adding context to your JSON via the JSON-LD's @context

Slide 19

Slide 19 text

@context { "@context": { "name": "http://xmlns.com/foaf/0.1/name", "born": { "@id": "http://schema.org/birthDate", "@type": "http://www.w3.org/2001/XMLSchema#date" }, "spouse": { "@id": "http://schema.org/spouse", "@type": "@id" } } } https://json-ld.org/contexts/person.jsonld

Slide 20

Slide 20 text

Expanded form [ {"@id": "http://dbpedia.org/resource/John_Lennon", "http://schema.org/birthDate": [ { "@type": "http://www.w3.org/2001/XMLSchema#date", “@value": "1940-10-09"}], "http://xmlns.com/foaf/0.1/name": [ {"@value": "John Lennon"}], "http://schema.org/spouse": [ {"@id": "http://dbpedia.org/resource/Cynthia_Lennon"}] }]

Slide 21

Slide 21 text

Triples – Subject, Predicate, Object "1940-10-09"^^ . . "John Lennon" .

Slide 22

Slide 22 text

Other people’s data

Slide 23

Slide 23 text

Reading Somebody Else’s JSON { "@context": "https://example.com/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "personName": "John Lennon", "bornOn": "1940-10-09", "marriedTo": "http://dbpedia.org/resource/Cynthia_Lennon" }

Slide 24

Slide 24 text

Their @context { "@context": { "personName": "http://xmlns.com/foaf/0.1/name", "bornOn": { "@id": "http://schema.org/birthDate", "@type": "http://www.w3.org/2001/XMLSchema#date" }, "marriedTo": { "@id": "http://schema.org/spouse", "@type": "@id" } } } http://example.com/person.jsonld

Slide 25

Slide 25 text

Triples – Subject, Predicate, Object "1940-10-09"^^ . . "John Lennon" .

Slide 26

Slide 26 text

Knowing from the Knowledge Graph

Slide 27

Slide 27 text

Knowledge Graphs • Can store any Linked Data triples  Even data your application my not (yet) understand • Can be used to answer interesting questions  “Who else was married to John Lennon?” • Allows querying across the entire graph and mixing output results  “What world events happened the year John Lennon was born?”  “What was John’s first song after marrying Yoko Ono?”

Slide 28

Slide 28 text

Projects to Watch • W3C Web of Things Working Group  Combines JSON-LD and JSON Schema + Hypermedia affordances  Allowing cross-product sensor output understanding across meaningful IoT data • LevelGraph  JavaScript-based knowledge graph  Playground that supports JSON-LD, Turtle, and other Linked Data formats • JSON-LD Community Group  Long running W3C Community Group focused on exploring and implementing JSON-LD

Slide 29

Slide 29 text

Thanks! bigbluehat.com GitHub | Twitter