Introduction to JSON-LD
Bo-Kai Hsu
許許許博博博凱凱凱
January 06, 2016
1 / 29Introduction to JSON-LD
N
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
2 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
3 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the problem with JSON ?
1 {2 " i d " : 3 ,3 "number" : 4 ,4 " va l u e " : 5 ,5 " count " : 66 }
What’s the meaning of this JSON ?
The first problem is ambiguity of JSON !!
4 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the problem with JSON ?
1 {2 " i d " : 3 ,3 "number" : 4 ,4 " va l u e " : 5 ,5 " count " : 66 }
What’s the meaning of this JSON ?
The first problem is ambiguity of JSON !!
4 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the problem with JSON ?
1 {2 " i d " : 3 ,3 "number" : 4 ,4 " va l u e " : 5 ,5 " count " : 66 }
What’s the meaning of this JSON ?
The first problem is ambiguity of JSON !!
4 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the meaning of this JSON?
1 {2 "name" : "Bob" ,3 "number" : 17 ,4 " pe r c en t age " : 32 . 3 ,5 " s t e a l " : 2 . 2 ,6 " a s s i s t " 7 .57 }
describing a student named Bob?
describing a basketball player named Bob?
the same JSON means different?
5 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the meaning of this JSON?
1 {2 "name" : "Bob" ,3 "number" : 17 ,4 " pe r c en t age " : 32 . 3 ,5 " s t e a l " : 2 . 2 ,6 " a s s i s t " 7 .57 }
describing a student named Bob?
describing a basketball player named Bob?
the same JSON means different?
5 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the meaning of this JSON?
1 {2 "name" : "Bob" ,3 "number" : 17 ,4 " pe r c en t age " : 32 . 3 ,5 " s t e a l " : 2 . 2 ,6 " a s s i s t " 7 .57 }
describing a student named Bob?
describing a basketball player named Bob?
the same JSON means different?
5 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
What’s the meaning of this JSON?
1 {2 "name" : "Bob" ,3 "number" : 17 ,4 " pe r c en t age " : 32 . 3 ,5 " s t e a l " : 2 . 2 ,6 " a s s i s t " 7 .57 }
describing a student named Bob?
describing a basketball player named Bob?
the same JSON means different?
5 / 29Introduction to JSON-LD
N
Why Using JSON-LD
Why Using JSON-LD
different JSON means the same?
1 {2 " p l a y e r " : "Bob" ,3 " Id " : 17 ,4 " shoo t i n g " : 32 . 3 ,5 "ST" : 2 . 2 ,6 "AST" : 7 . 57 }
describing a basketball player named Bob?
6 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
7 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific
specifying the clear definition by an URI
http://schema.org provides shared common vocabulary
1 {2 " ht tp : // schema . org /name" : "Bob" ,3 " ht tp : // example . com/JerseyNumber " : 17 ,4 " ht tp : // example . com/ F i e l dGoa lP e r c e n t a g e " : 32 .35 }
specific but too complicated ?
8 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific
specifying the clear definition by an URI
http://schema.org provides shared common vocabulary
1 {2 " ht tp : // schema . org /name" : "Bob" ,3 " ht tp : // example . com/JerseyNumber " : 17 ,4 " ht tp : // example . com/ F i e l dGoa lP e r c e n t a g e " : 32 .35 }
specific but too complicated ?
8 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Concise
concise but ambiguous ?
1 {2 " p l a y e r " : "Bob" ,3 " Id " : 17 ,4 " shoo t i n g " : 32 . 3 ,5 "ST" : 2 . 2 ,6 "AST" : 7 . 57 }
9 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific And Concise
With "@context", being specific and concise!!
1 {2 "@context " : " b a s k e t b a l l " ,3 " p l a y e r " : "Bob" ,4 " Id " : 17 ,5 " shoo t i n g " : 32 . 3 ,6 "ST" : 2 . 2 ,7 "AST" : 7 . 58 }
10 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific And Concise
With "@context", being concise and specific !!
1 {2 "@context " : {3 "name" : " h t tp : // schema . org /name" ,4 "number" : " h t tp : // example . com/JerseyNumber " ,5 "FGP" : " h t tp : // example . com/ F i e l dGoa lP e r c e n t a g e "6 } ,7 "name" : "Bob" ,8 "number" : 17 ,9 "FGP" : 32 .3
10 }
JSON-LD uses "@context" to define document context
11 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Context
"@context" defines
1 What do properties exactly means?2 What type is the value?
What type is "02.15"?
1 Date (February 15) ?2 Time (a quarter past two) ?3 Decimal (2.15) ?4 Percentage (2.15%)?
12 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific And Concise
define type
1 {2 "@context " : { . . . } ,3 "name" : "Bob" ,4 "number" : {5 "@va lue " : "17" ,6 "@type" : " h t tp : //www.w3 . org /2001/XMLSchema#
i n t e g e r "7 }8 "FGP" : {9 "@va lue " : " 32 .3 " ,
10 "@type" : " h t tp : //www.w3 . org /2001/XMLSchema#dec ima l "
11 }12 }
13 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific And Concise
define type in "@context"1 {2 "@context " : {3 "name" : " h t tp : // schema . org /name" ,4 "number" : {5 "@id" : " h t tp : // example . com/JerseyNumber " ,6 "@type" : " h t tp : //www . . . / XMLSchema#i n t e g e r "7 }8 "FGP" : {9 "@id" : " h t tp : // example . com/ F i e l dGoa lPe . . . " ,
10 "@type" : " h t tp : //www . . . / XMLSchema#dec ima l "11 }12 } ,13 "name" : "Bob" ,14 "number" : "17" ,15 "FGP" : " 32 .3 "16 }
14 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific And Concise
context separation
1 {2 "@context " : " h t tp : // j son−l d . o rg / c on t e x t s / b a s k e t b a l l .
j s o n l d " ,3 "name" : "Bob" ,4 "number" : "17" ,5 "FGP" : " 32 .3 "6 }
HTTP Link Header
JSON-LD is as simple as JSON and compatible with ordinary JSONdocument
15 / 29Introduction to JSON-LD
N
How To Deal With Ambiguity
Be Specific And Concise
which Bob is ?
1 {2 "@context " : " h t tp : // j son−l d . . . / b a s k e t b a l l . j s o n l d " ,3 "@id" : " h t tp : // example . com/ b a s k e t b a l l / p l a y e r s /bob" ,4 "@type" : " h t tp : // schema . org /Person " ,5 "name" : "Bob" ,6 "number" : "17" ,7 "FGP" : " 32 .3 "8 }
JSON-LD gives your data an identifier
16 / 29Introduction to JSON-LD
N
How To Deal With Linking
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
17 / 29Introduction to JSON-LD
N
How To Deal With Linking
Why Using JSON-LD
The second problem is how to link JSON !!
1 {2 "name" : " A l i c e " ,3 "number" : "27" ,4 "FGP" : " 50 .3 "5 }
1 {2 "name" : "Bob" ,3 "number" : "17" ,4 "FGP" : " 32 .3 " ,5 " he l p " : [ " A l i c e " , . . . ]6 }
which Alice is ?
JSON has no built-in support for hyperlink
18 / 29Introduction to JSON-LD
N
How To Deal With Linking
Why Using JSON-LD
The second problem is how to link JSON !!
1 {2 "name" : " A l i c e " ,3 "number" : "27" ,4 "FGP" : " 50 .3 "5 }
1 {2 "name" : "Bob" ,3 "number" : "17" ,4 "FGP" : " 32 .3 " ,5 " he l p " : [ " A l i c e " , . . . ]6 }
which Alice is ?
JSON has no built-in support for hyperlink
18 / 29Introduction to JSON-LD
N
How To Deal With Linking
Linking By Identifier
JSON-LD gives your data an identifier, which is convenient for linking1 {2 "@context " : " h t tp : // j son−l d . . . / b a s k e t b a l l . j s o n l d " ,3 "@id" : " h t tp : // example . com/ b a s k e t b a l l / p l a y e r s / a l i c e " ,4 "name" : " A l i c e " ,5 }
1 {2 "@context " : " h t tp : // j son−l d . . . / b a s k e t b a l l . j s o n l d " ,3 "@id" : " h t tp : // example . com/ b a s k e t b a l l / p l a y e r s /bob" ,4 "name" : "Bob" ,5 " he l p " : [ {6 "@id" : " h t tp : // example . com/ b a s k e t b a l l / p l a y e r s /
a l i c e "7 } , . . .8 ]9 }
19 / 29Introduction to JSON-LD
N
How To Deal With Linking
Linking By Identifier
JSON-LD serializes a labeled directed graph
JSON-LD can describe almost everything
without ambiguity, JSON-LD is a machine-readable data
20 / 29Introduction to JSON-LD
N
What Is JSON-LD
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
21 / 29Introduction to JSON-LD
N
What Is JSON-LD
JSON for Linking Data
JSON
a kind of simple properties value pairs data format used in transmittingdata between websites
Linking Data
a way to create network of sdandard-based machine-readable data acrosewebsites
JSON-LD
a lightweight syntax to serialize Linking Data based on JSON
JSON-LD 1.0 specification http://www.w3.org/TR/json-ld/
22 / 29Introduction to JSON-LD
N
What Is JSON-LD
JSON for Linking Data
JSON
a kind of simple properties value pairs data format used in transmittingdata between websites
Linking Data
a way to create network of sdandard-based machine-readable data acrosewebsites
JSON-LD
a lightweight syntax to serialize Linking Data based on JSON
JSON-LD 1.0 specification http://www.w3.org/TR/json-ld/
22 / 29Introduction to JSON-LD
N
What Is JSON-LD
JSON for Linking Data
JSON
a kind of simple properties value pairs data format used in transmittingdata between websites
Linking Data
a way to create network of sdandard-based machine-readable data acrosewebsites
JSON-LD
a lightweight syntax to serialize Linking Data based on JSON
JSON-LD 1.0 specification http://www.w3.org/TR/json-ld/
22 / 29Introduction to JSON-LD
N
Applications of JSON-LD
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
23 / 29Introduction to JSON-LDN
Applications of JSON-LD
Search Engine Optimization
embedding JSON-LD in HTML document
1 <s c r i p t type=" a p p l i c a t i o n / l d+j s o n ">2 {3 "@context " : " h t tp : // schema . org " ,4 "@type" : "Person " ,5 "name" : "Bo−Kai " ,6 "age" : "25"7 }8 </s c r i p t >
making search engine know the meaning of data
24 / 29Introduction to JSON-LD
N
Applications of JSON-LD
Gmail
tagging action information in Gmail
1 <s c r i p t type=" a p p l i c a t i o n / l d+j s o n ">2 {3 "@context " : " h t tp : // schema . org " ,4 "@type" : " Re s t au r an tRe s e r v eAc t i o n " ,5 " l o c a t i o n " : " Ta i p e i " ,6 " p a r t i c i p a n t s " : [ {"@id " : " h t tp : / / . . . " } , . . . ]7 }8 </s c r i p t >
making active service possible
25 / 29Introduction to JSON-LD
N
Applications of JSON-LD
API Documentation
describing API document in JSON-LD
1 {2 "@context " : " h t tp : //www.w3 . org / ns / hydra / co r e#" ,3 "@type" : "ApiDocumentat ion " ,4 " s uppo r t e dC l a s s " : [ . . . ] ,5 " s ta tu sCode " : [ . . . ]6 }
making API document browsable
26 / 29Introduction to JSON-LD
N
Conclusion
Outline
1 Why Using JSON-LD
2 How To Deal With Ambiguity
3 How To Deal With Linking
4 What Is JSON-LD
5 Applications of JSON-LD
6 Conclusion
27 / 29Introduction to JSON-LD
N
Conclusion
JSON-LD
1 make data readable for machine without ambiguity
2 make data link together
3 be applied in SEO, Gmail, and API documentation
28 / 29Introduction to JSON-LD
N
Conclusion
QuestionsRefrerence
1 http://json-ld.org/
2 http://www.programmableweb.com/news/how-to-build-hypermedia-apis-json-ld-and-hydra/analysis/2015/07/30
3 https://www.youtube.com/watch?v=fJCtaNRxg9M
4 http://www.seoskeptic.com/what-is-json-ld/
5 https://developers.google.com/schemas/gmail/actions
6 http://www.w3.org/TR/json-ld/
7 https://www.youtube.com/watch?v=4x_xzT5eF5Q
8 https://www.youtube.com/watch?v=vioCbTo3C-4
9 https://www.youtube.com/watch?v=OGg8A2zfWKg&index=6&list=PLjaODRwyGTalY6VkIsKyuPx-CsZV2c9Xv
29 / 29Introduction to JSON-LD
N