json-ld - csee.umbc.edu€¦ · evaluaon l json is simpler than xml and more compact – no closing...

23
JSON-LD

Upload: others

Post on 01-Oct-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

JSON-LD

Page 2: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

JSONasanXMLAlterna3vel Light-weightXMLalterna0vefordata-interchange

l JSON=JavaScriptObjectNota0on–  It’sreallylanguageindependent–  Mostprogramminglanguagescaneasilyreaditandinstan0ateobjects

l DefinedinRFC4627l Startedgainingtrac0on~2006,nowwidelyused

l hQp://json.org/hasmoreinforma0on

Page 3: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

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€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

TheBNFissimple

Page 5: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Evalua3onl JSONissimplerthanXMLandmorecompact

–  Noclosingtags,butifyoucompressXMLandJSONthedifferenceisnotsogreat

–  XMLparsingishardbecauseofitscomplexity

l JSONhasabeQerfitforOOsystemsthanXML,butnotasextensible

l Preferredforsimpledataexchangebymanyl MongoDB:‘NoSQL’databaseforJSONobjectsl Elas0cSearch:Lucene-basedIRsystemusingJSONtorepresentdocuments

Page 6: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

JSON-LD

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

Page 7: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Inthebeginning

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

Page 8: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

AbitbeCer

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

l The'@id'keywordmeans'Thisvalueisaniden0fierthatisanIRI'

Page 9: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

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

[1]Thismeansthat'name'isshorthandfor'hQp://schema.org/name'[2]Thismeansthat'image'isshorthandfor'hQp://schema.org/image'[3]Thismeansthatastringvalueassociatedwith'image'shouldbeinterpretedasaniden0fierthatisanIRI[4]Thismeansthat'homepage'isshorthandfor'hQp://schema.org/url'[5]Thismeansthatastringvalueassociatedwith'homepage'shouldbeinterpretedasaniden0fierthatisanIRI

Page 10: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Referenceanexternalcontext

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

Page 11: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

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

Page 12: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

ExternalContext?

l FetchhQp://json-ld.org/contexts/person.jsonldcurlhQp://json-ld.org/contexts/person.jsonldReturnsaJSONobjectdefiningthecontext

l FetchhQp://schema.org/curl–LhQp://schema.org/L–  ReturnsHTMLpage,sinceitsdefaultapplica0on/typeisHTML

l Fetchcurl--header"Accept:applica0on/ld+json"-LhQp://schema.org/

Page 13: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Makingasser3onsaboutthings

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

Page 14: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Addingadefaultvocabulary

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

Page 15: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

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

Page 16: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Embeddingotherobjects

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

Page 17: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

GooglelooksforJSON-LD

l GooglelooksforandusessomeJSON-LDmarkup(e.g.,fororganiza0ons)

l PutaJSON-LDobjectinheadorbodyofwebpagewrappedwithscripttags:<scripttype="applica0on/ld+json">{...}</script>

Page 18: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML
Page 19: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML
Page 20: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

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

Page 21: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

hCp://json-ld.org/

Page 22: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

JSON-LDPlayground

Page 23: JSON-LD - csee.umbc.edu€¦ · Evaluaon l JSON is simpler than XML and more compact – No closing tags, but if you compress XML and JSON the difference is not so great – XML

Conclusion

l JSON-LDisagoodsolu0ontopuzngblocksofseman0cdataonwebpages

l Aimedatpublishlinkeddata,notontologies,i.e.,ABOXnotTBOX

l Toolsavailableforextrac0ngRDFtriplesl SearchcompanieslookforandJSON-LDthatusevocabulariestheyunderstand(i.e.,schema.org)