0% found this document useful (0 votes)
70 views6 pages

Json LD Presentation

This document provides an overview of JSON as an alternative to XML for data interchange. It describes how JSON is a lightweight format that is easier to parse than XML. JSON data is written as JavaScript objects and can represent nested objects and arrays. The document also introduces JSON-LD as a W3C recommendation for representing RDF data in JSON.

Uploaded by

mauricioville
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views6 pages

Json LD Presentation

This document provides an overview of JSON as an alternative to XML for data interchange. It describes how JSON is a lightweight format that is easier to parse than XML. JSON data is written as JavaScript objects and can represent nested objects and arrays. The document also introduces JSON-LD as a W3C recommendation for representing RDF data in JSON.

Uploaded by

mauricioville
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

JSON

 as  an  XML  Alterna3ve  


l  JSON  is  a  light-­‐weight  alterna3ve  to  XML  for  data-­‐

JSON-­‐LD   interchange  
l  JSON  =  JavaScript  Object  Nota3on  
  –  It’s  really  language  independent  
–  most  programming  languages  can  easily  read  it  and  
instan3ate  objects  or  some  other  data  structure  
l  Defined  in  RFC  4627  

l  Started  gaining  trac3on  ~2006  and  now  widely  used  

l  hQp://json.org/has  more  informa3on  

Example   The  BNF  is  simple    


{"firstName":  "John",   l  This  is  a  JSON  object  with  
 "lastName"  :  "Smith",  
five  key-­‐value  pairs  
 "age"                    :  25,  
 "address"      :   l  Objects  are  wrapped  by  
       {"streetAdr”  :  "21  2nd  Street",   curly  braces  
           "city"                  :  "New  York",  
l  There  are  no  object  IDs  
           "state"              :  "NY",  
           ”zip"                    :  "10021"},   l  Keys  are  strings  
 "phoneNumber":   l  Values  are  numbers,  
       [{"type"    :  "home",  
strings,  objects  or  arrays  
           "number":  "212  555-­‐1234"},  
         {"type"    :  "fax",   l  Arrays  are  wrapped  by  
           "number”  :  "646  555-­‐4567"}]   square  brackets  
 }  

1  
Evalua3on   JSON-­‐LD  
l  JSON  is  simpler  than  XML  and  more  compact  
JSON-­‐LD  is  a  W3C  recommenda3on  for  represen3ng  
–  No  closing  tags,  but  if  you  compress  XML  and  JSON  the   RDF  data  as  JSON  objects  
difference  is  not  so  great   {"@context":  {  
–  XML  parsing  is  hard  because  of  its  complexity          "name":  "hQp://xmlns.com/foaf/0.1/name",  
       "homepage":  {  
l  JSON  has  a  beQer  fit  for  OO  systems  than  XML,  but  
           "@id":  "hQp://xmlns.com/foaf/0.1/workplaceHomepage",  
not  as  extensible              "@type":  "@id"  
       },  
l  Preferred  for  simple  data  exchange  by  many  
       "Person":  "hQp://xmlns.com/foaf/0.1/Person"  
l  MongoDB  is  a  very  popular  open-­‐source  ‘NoSQL’      },  
database  for  JSON  objects      "@id":  "hQp://me.markus-­‐lanthaler.com",  
   "@type":  "Person",  
   "name":  "Markus  Lanthaler",  
   "homepage":  "hQp://www.tugraz.at/"  
}  

In  the  beginning   A  bit  beCer  


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

l  The  '@id'  keyword  means  'This  value  is  an  


iden3fier  that  is  an  IRI'  

2  
Define  a  context   Reference  an  external  context  
{  "@context":  
   {  
       "name":  "hQp://schema.org/name",            %  [1]  
{  
       "image":  {      "@context":  "hQp://json-­‐ld.org/contexts/person.jsonld",  
           "@id":  "hQp://schema.org/image",          %  [2]  
           "@type":  "@id"                                                                              %  [3]      "name":  "Manu  Sporny",  
       },  
       "homepage":  {      "homepage":  "hQp://manu.sporny.org/",  
           "@id":  "hQp://schema.org/url",                  %  [4]  
           "@type":  "@id"                                                                          %  [5]  
   "image":  "hQp://manu.sporny.org/images/manu.png"  
       }  }  }   }  
[1]  This  means  that  'name'  is  shorthand  for  'hQp://schema.org/name'    
[2]  This  means  that  'image'  is  shorthand  for  'hQp://schema.org/image'      
[3]  This  means  that  a  string  value  associated  with  'image'  should  be  interpreted  as  an  
iden3fier  that  is  an  IRI    
[4]  This  means  that  'homepage'  is  shorthand  for  'hQp://schema.org/url'    
[5]  This  means  that  a  string  value  associated  with  'homepage'  should  be  interpreted  as  
an  iden3fier  that  is  an  IRI    

Add  context  inline   Making  asser3ons  about  things  


{"@context":  
{  
   {  
       "name":  "hQp://schema.org/name",      "@context":  {  
       "image":  {  
           "@id":  "hQp://schema.org/image",  
       ...  
           "@type":  "@id"          "Restaurant":  "hQp://schema.org/Restaurant",    
       },  
       "homepage":  {  
       "Brewery":  "hQp://schema.org/Brewery"  
           "@id":  "hQp://schema.org/url",      }  
           "@type":  "@id"  
       }      "@id":  "hQp://example.org/places#BrewEats",  
   },      "@type":  [  "Restaurant",  "Brewery"  ],  
   "name":  "Manu  Sporny",  
   "homepage":  "hQp://manu.sporny.org/",      ...  
   "image":  "hQp://manu.sporny.org/images/manu.png"  
}  
}  

3  
Adding  a  default  vocabulary   Mixing  vocabularies  
{   {  
   "@context":  
   "@context":  {      {  
       "@vocab":  "hQp://schema.org/"          "xsd":  "hQp://www.w3.org/2001/XMLSchema#",  
       "foaf":  "hQp://xmlns.com/foaf/0.1/",  
   }  
       "foaf:homepage":  {  "@type":  "@id"  },  
   "@id":  "hQp://example.org/places#BrewEats",          "picture":  {  "@id":  "foaf:depic3on",  "@type":  "@id"  }  
   "@type":  "Restaurant",      },  
   "@id":  "hQp://me.markus-­‐lanthaler.com/",  
   "name":  "Brew  Eats"      "@type":  "foaf:Person",  
   ...      "foaf:name":  "Markus  Lanthaler",  
   "foaf:homepage":  "hQp://www.markus-­‐lanthaler.com/",  
}  
   "picture":  "hQp://twiQer.com/account/profile_image/markuslanthaler"  
  }  
 

Embedding  other  objects   Google  looks  for  JSON-­‐LD  


{   l  Google  looks  for  and  uses  some  JSON-­‐LD  markup  (e.g.,  
     ...   for  organiza3ons)  
   "name":  "Manu  Sporny",   l  Put  a  JSON-­‐LD  object  in  the  head  of  a  web  page  

   "foaf:knows":   wrapped  with  script  tags:  


   {   <script  type="applica3on/ld+json">  
       "@type":  "Person",   {...}  
</script>    
       "name":  "Gregg  Kellogg",  
   }  
...  
}  

4  
hCp://json-­‐ld.org/   Conclusion  
l  JSON-­‐LD  is  a  good  solu3on  to  puzng  blocks  of  
seman3c  data  on  web  pages  
l  It’s  aimed  at  publish  linked  data,  not  ontologies,  i.e..  
ABOX  not  TBOX  
l  Tools  are  available  for  extrac3ng  their  content  as  RDF  
triples  
l  Search  companies  are  beginning  to  look  for  and  JSON-­‐
LD  in  web  pages  that  uses  vocabularies  they  
understand  (i.e.,  schema.org)  
l  Look  for  more  of  this  in  the  future  

5  
hCp://json-­‐ld.org/playground/  

6  

You might also like