json-ld - csee.umbc.edu€¦ · google looks for json-ld lgoogle looks for and uses some json-ld...

24
JSON-LD

Upload: others

Post on 01-Oct-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

JSON-LD

Page 2: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

JSONasanXMLAlternativel Light-weightXMLalternativefordata-interchange

l JSON=JavaScriptObjectNotation– It’sreallylanguageindependent– Mostprogramminglanguagescaneasilyreaditandinstantiateobjects

lDefinedinRFC4627lStartedgainingtraction~2006,nowwidelyused

lhttp://json.org/ hasmoreinformation

Page 3: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Example

{"firstName":"John","lastName":"Smith","age":25,"address":{"streetAdr”:"212ndStreet","city":"NewYork","state":"NY",”zip":"10021"},

"phoneNumber":[{"type":"home","number":"212555-1234"},{"type":"fax","number”:"646555-4567"}]

}

l ThisisaJSONobjectwithfivekey-valuepairs

l Objectsarewrappedbycurlybraces

l TherearenoobjectIDsl Keysarestringsl Valuesarenumbers,strings,objectsorarrays

l Arraysarewrappedbysquarebrackets

Page 4: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

TheBNFissimple

Page 5: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Evaluation

l JSONissimplerthanXMLandmorecompact– Noclosingtags,butifyoucompressXMLandJSONthedifferenceisnotsogreat

– XMLparsingishardbecauseofitscomplexity

l JSONhasabetterfitforOOsystemsthanXML,butnotasextensible

lPreferredforsimpledataexchangebymanylMongoDB:‘NoSQL’databaseforJSONobjectslElasticSearch:Lucene-basedIRsystemusingJSONtorepresentdocuments

Page 6: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

JSON-LD

JSON-LD:2014W3Crecommendation forrepresentingRDFdataasJSONobjects{"@context":{"name":"http://xmlns.com/foaf/0.1/name","homepage":{"@id":"http://xmlns.com/foaf/0.1/workplaceHomepage","@type":"@id"},"Person":"http://xmlns.com/foaf/0.1/Person"},"@id":"http://me.markus-lanthaler.com","@type":"Person","name":"MarkusLanthaler","homepage":"http://www.tugraz.at/"}

Page 7: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Inthebeginning

{"name":"ManuSporny","homepage":"http://manu.sporny.org/","image":"http://manu.sporny.org/images/manu.png"}

Page 8: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Abitbetter

{"http://schema.org/name":"ManuSporny","http://schema.org/url":{"@id":"http://manu.sporny.org/"}"http://schema.org/image":

{"@id":"http://manu.sporny.org/images/manu.png"}}

lThe'@id'keywordmeans'ThisvalueisanidentifierthatisanIRI'

Page 9: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Defineacontext{"@context":{"name":"http://schema.org/name",%[1]"image":{"@id":"http://schema.org/image",%[2]"@type":"@id"%[3]},"homepage":{"@id":"http://schema.org/url",%[4]"@type":"@id" %[5]}}}

[1]means'name'isshortfor'http://schema.org/name'[2]means'image'isshortfor'http://schema.org/image'[3]meansastringvalueassociatedwith'image'shouldbeinterpretedasanidentifierthatisanIRI[4]means'homepage'isshortfor'http://schema.org/url'[5]meansastringvalueassociatedwith'homepage'shouldbeinterpretedasanidentifierthatisanIRI

Page 10: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Referenceanexternalcontext

{"@context":"http://json-ld.org/contexts/person.jsonld","name":"ManuSporny","homepage":"http://manu.sporny.org/","image":"http://manu.sporny.org/images/manu.png"}

Page 11: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Addcontextinline{"@context":{"name":"http://schema.org/name","image":{"@id":"http://schema.org/image","@type":"@id"},"homepage":{"@id":"http://schema.org/url","@type":"@id"}},"name":"ManuSporny","homepage":"http://manu.sporny.org/","image":"http://manu.sporny.org/images/manu.png"}

Page 12: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

ExternalContext?

lFetchhttp://json-ld.org/contexts/person.jsonldcurlhttp://json-ld.org/contexts/person.jsonldReturns aJSONobjectdefiningthecontext

lFetchhttp://schema.org/curl–Lhttp://schema.org/– ReturnsHTMLpage,sinceitsdefaultapplication/typeisHTML

lFetchcurl--header"Accept:application/ld+json"-Lhttp://schema.org/

Page 13: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Makingassertionsaboutthings

{"@context":{..."Restaurant":"http://schema.org/Restaurant","Brewery":"http://schema.org/Brewery"}"@id":"http://example.org/places#BrewEats","@type":["Restaurant","Brewery"],...}

Page 14: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Addingadefaultvocabulary

{"@context":{"@vocab":"http://schema.org/"}"@id":"http://example.org/places#BrewEats","@type":"Restaurant","name":"BrewEats"...}

Page 15: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Mixingvocabularies{"@context":{"xsd":"http://www.w3.org/2001/XMLSchema#","foaf":"http://xmlns.com/foaf/0.1/","foaf:homepage":{"@type":"@id"},"picture":{"@id":"foaf:depiction","@type":"@id"}},"@id":"http://me.markus-lanthaler.com/","@type":"foaf:Person","foaf:name":"MarkusLanthaler","foaf:homepage":"http://www.markus-lanthaler.com/","picture":"http://twitter.com/account/profile_image/markuslanthaler"}

Page 16: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Embeddingotherobjects

{..."name":"ManuSporny","foaf:knows":{"@type":"Person","name":"GreggKellogg",}...}

Page 17: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

GooglelooksforJSON-LD

lGooglelooksforandusessomeJSON-LDmarkup(e.g.,fororganizations)

lPutaJSON-LDobjectinheadorbodyofwebpagewrappedwithscripttags:<scripttype="application/ld+json">{...}</script>

Page 18: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page
Page 19: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page
Page 20: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

https://search.google.com/structured-data/testing-tool

Page 21: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page
Page 22: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

http://json-ld.org/

Page 23: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

JSON-LDPlayground

Page 24: json-ld - csee.umbc.edu€¦ · Google looks for JSON-LD lGoogle looks for and uses some JSON-LD markup (e.g., for organizations) lPut a JSON-LD object in head or body of web page

Conclusion

l JSON-LDisagoodsolutiontoputtingblocksofsemanticdataonwebpages

lAimedatpublishinglinkeddata,notontologies,i.e.,ABOXnotTBOX

lToolsavailableforextractingRDFtripleslSearchengineslookforanduseJSON-LDthatusevocabulariestheyunderstand(i.e.,schema.org)