Warning:
This wiki has been archived and is now read-only.

JSON-Serialization-Examples

From RDF Working Group Wiki
Jump to: navigation, search

JSON Serializations By Example

Sample Graphs

Error creating thumbnail: Unable to save thumbnail to destination

Basic Example

@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix  dc:   <http://purl.org/dc/elements/1.1/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix :      <http://example/> .

<http://jondoe.example.org/#me> a foaf:Person ;
	foaf:nick "Jonny" ;
	foaf:givenname "Jon" ;
	foaf:family_name "Doe" ;
	foaf:depiction <http://jondoe.example.org/me.jpg> ;
	foaf:homepage <http://jondoe.example.org/> ;
	foaf:interest <http://dbpedia.org/resource/Film> ;
	foaf:knows <http://janedoe.example.org/#me> ;
 	foaf:knows [ foaf:name "John Smith" ] .

<http://janedoe.example.org/#me> a foaf:Person ;
	foaf:name "Jane Doe" .


:book1
  dc:creator <http://jondoe.example.org/#me> ;
  dc:contributor ( <http://janedoe.example.org/#me> [ foaf:name "John Smith" ] ) ;
  dc:date "2011"^^xsd:gYear ;
  dc:title  "Swansea" ;
  dc:subject  <http://en.wikipedia.org/wiki/Swansea> .

<http://en.wikipedia.org/wiki/Swansea>
  dc:date     "2011-03-23"^^xsd:date ;
  rdfs:label  "Swansea"@en , "Abertawe"@cy .

Advanced Example (based on this GoodRelations example)

@prefix gr: <http://purl.org/goodrelations/v1#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://business.example.org/openinghours.html#business> a gr:BusinessEntity ;
     rdfs:label "Example Business, Inc."@en ;
     gr:hasPOS <http://business.example.org/openinghours.html#shop> ;
     gr:legalName "Example Business, Inc."@en ;
     foaf:page <http://business.example.com>, <http://business.example.org/openinghours.html> ;
     vcard:fn "Example Business, Inc."@en ;
     vcard:geo
         [ vcard:latitude "49.0202626"^^xsd:float ;
           vcard:longitude "12.8407428"^^xsd:float
         ] ;
     vcard:tel "+49-12-3546789"^^xsd:string ;
     vcard:url <http://business.example.com> .

 <http://business.example.org/openinghours.html#shop> a gr:LocationOfSalesOrServiceProvisioning ;
      gr:hasOpeningHoursSpecification
          <http://business.example.org/openinghours.html#mon>,
          <http://business.example.org/openinghours.html#tue>,
          <http://business.example.org/openinghours.html#wed>,
          <http://business.example.org/openinghours.html#thu>,
          <http://business.example.org/openinghours.html#fri>,
          <http://business.example.org/openinghours.html#sat>.

<http://business.example.org/openinghours.html#mon> a gr:OpeningHoursSpecification ;
     gr:closes "18:00:00"^^xsd:time ;
     gr:hasOpeningHoursDayOfWeek gr:Monday ;
     gr:opens "08:00:00"^^xsd:time .

<http://business.example.org/openinghours.html#tue> a gr:OpeningHoursSpecification ;
    gr:closes "18:00:00"^^xsd:time ;
    gr:hasOpeningHoursDayOfWeek gr:Tuesday ;
    gr:opens "08:00:00"^^xsd:time .

<http://business.example.org/openinghours.html#wed> a gr:OpeningHoursSpecification ;
    gr:closes "14:00:00"^^xsd:time ;
    gr:hasOpeningHoursDayOfWeek gr:Wednesday ;
    gr:opens "08:00:00"^^xsd:time .
     
<http://business.example.org/openinghours.html#thu> a gr:OpeningHoursSpecification ;
    gr:closes "18:00:00"^^xsd:time ;
    gr:hasOpeningHoursDayOfWeek gr:Thursdays ;
    gr:opens "08:00:00"^^xsd:time .

<http://business.example.org/openinghours.html#fri> a gr:OpeningHoursSpecification ;
    gr:closes "20:00:00"^^xsd:time ;
    gr:hasOpeningHoursDayOfWeek gr:Friday ;
    gr:opens "08:00:00"^^xsd:time .

<http://business.example.org/openinghours.html#sat> a gr:OpeningHoursSpecification ;
     gr:closes "15:00:00"^^xsd:time ;
     gr:hasOpeningHoursDayOfWeek gr:Saturday ;
     gr:opens "09:00:00"^^xsd:time .

Artificial data which cover many cases and many Turtle shortcuts:

@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://example/> .

:x1 :p1 1 ;
    :p2 1.0 ;
    :p3 1.0e0 ;
    :p4 () ;
    :p5 (1 2 "three" ) ;
    :p6  [ :q 57 ; :q 89 ] ;
    :p7 _:a .

_:a  :p1 :z ;
     :p2 "str" ;
     :p3 "str"^^xsd:string .

[]  :p :z .

:z rdfs:label "Swansea"@en , "Abertawe"@cy ;
   :q1 "2011-03-23T13:40:22.489+00:00"^^xsd:dateTime ;
   :q2 "2011-03-23Z"^^xsd:date ;
   :q3 "2011-03-23"^^xsd:date ;
   :q4 "2011+01:00"^^xsd:gYear ;
   :q5 "2011"^^xsd:gYear .

("a" "b" "c" ) :p [ :p (1 2) , (3 4) ] .

[ :p (1 2) , (3 4) ] :p ("a" "b" "c" ) .

and some short forms that are not legal Turtle, but represent legal RDF triples. They are SPARQL.

("a" "b" "c" ) .

[ :p (1 2) , (3 4) ] .

JSON Serializations Lineup

Error creating thumbnail: Unable to save thumbnail to destination

Shared Example for Serialization Lineup (Turtle)

@prefix foaf:     <http://xmlns.com/foaf/0.1/> .
@prefix xsd:      <http://www.w3.org/2001/XMLSchema#> .
@prefix vcard:    <http://www.w3.org/2006/vcard/ns#> .
@prefix iCollide: <http://example.org/icollide#> .
@prefix :         <http://example/> .

<http://jondoe.example.org/#me> a foaf:Person ;
  foaf:name "Jon" ;
  iCollide:name "Jon" ;
  foaf:depiction <http://jondoe.example.org/me.jpg> ;
  foaf:knows ( <http://janedoe.example.org/#me> [ foaf:name "John Smith" ] ) ;
  foaf:birthday "2010-03-23T13:40:22.489+00:00"^^xsd:dateTime ;
  foaf:age 1 ;
  foaf:description "Just another Jon Doe"@en, "Justement un autre Jon Doe"@fr ;
  vcard:geo [
    vcard:latitude "49.0202626"^^xsd:float ;
    vcard:longitude "12.8407428"^^xsd:float
  ] ;
  vcard:tel "+49-12-3546789"^^xsd:string .

<http://janedoe.example.org/#me> a foaf:Person .

Remarks: We tried to compile a worst case real-world scenario of things that could potentially appear in Turtle, namely:

  • literals
  • literals with language tags
  • literals with trivial data types
  • literals with non-trivial data types
  • blank nodes
  • lists
  • IRIs
  • potentially colliding CURIE prefixes

Linked Data API

  {
    "format": "linked-data-api",
    "version": "0.2",
    "result": {
      "_about": "http://jondoe.example.org/#me",
      "type": "http://xmlns.com/foaf/0.1/Person",
      "foaf_name": "Jon",
      "iCollide_name": "Jon",
      "depiction": "http://jondoe.example.org/me.jpg",
      "knows": [
        "http://janedoe.example.org/#me",
        "_:b0"
      ],
      "birthday": "Tue Mar 23 2010 14:40:22 GMT+0100 (CET)",
      "age": 1,
      "description": [
        "Just another Jon Doe@en",
        "Justement un autre Jon Doe@fr"
      ],
      "geo": {
        "format": "linked-data-api",
        "version": "0.2",
        "result": {
          "latitude": "49.0202626^^xsd:float",
          "longitude": "12.8407428^^xsd:float"                    
        }
      },
      "tel": "+49-12-3546789^^xsd:string"
    }
  }
  
  {
    "format": "linked-data-api",
    "version": "0.2",
    "result": {
      "_about": "http://janedoe.example.org/#me",
      "type": "http://xmlns.com/foaf/0.1/Person"
    }
  }
  
  {
    "format": "linked-data-api",
    "version": "0.2",
    "result": {
      "_id": "_:b0",
      "name": "John Smith"
    }
  }              

Remarks:

  • Linked Data API boilerplate at the beginning
  • No concept of namespaces whatsoever (lossy RDF)
  • Microsyntax for language tags
  • Microsyntax for types
  • Microsyntax for subject (_about)

JRON

This is JRON 0.2, which hasn't been properly documented. It differs from JRON 0.1 in taking into account some comments from readers. Specificially, "node_id" and "iri" have been merged into "id", and the "__" has been replaced with "_". Also, this example shows something that wasn't clear in the spec, that when your data a single tree, you use a top-level { "_values": ... } wrapper.

{
    "_prefixes": {
	"foaf_": "http://xmlns.com/foaf/0.1/",
	"xsd_": "http://www.w3.org/2001/XMLSchema#",
	"vcard_": "http://www.w3.org/2006/vcard/ns#",     
	"rdfs_": "http://www.w3.org/2000/01/rdf-schema#",
	"iCollide_": "http://example.org/icollide#"
    }           ,
    "_values": 
    [
	{
	    "_id": "http://jondoe.example.org/#me",
	    "rdfs_type": { "_id": "foaf_Person" },
	    "foaf_name": "Jon",
	    "iCollide_name": "Jon",
	    "foaf_depiction": { "_id": "http://jondoe.example.org/me.jpg" },
	    "foaf_knows": 
	    [
		{ "_id": "http://janedoe.example.org/#me" },
		{ "foaf_name": "John Smith" }
	    ],
	    "foaf_birthday": {
		"_repr": "2010-03-23T13:40:22.489+00:00",
		"_type": "xsd_dateTime"
	    },
	    "foaf_age": 1,
	    "foaf_description": [
		{"_text": "Just another Jon Doe", "_lang": "en"}, 
		{"_text": "Justement un autre Jon Doe", "_lang": "fr"}
	    ],
	    "vcard_geo": {
		"vcard_latitude": {"_repr": "49.0202626", "_type": "xsd_float"},
		"vcard_longitude": {"_repr": "12.8407428", "_type": "xsd_float"}
	    },
	    "vcard_tel": {"_repr": "+49-12-3546789", "_type": "xsd_string"}
	},
	{
	    "_id": "http://janedoe.example.org/#me",
	    "rdfs_type": { "_id": "foaf_Person" }
	}
    ]
}

Remarks:

  • Concept of namespaces in __prefixes section. Could use ":" or "." as separator, at will.
  • Microsyntax for subject (_id)
  • Paired values for non-JSON data types -- in practice, the lat/lon would probably be doubles and thus just be { "vcard_latitude": 49.0202626, "vcard_longitude": 12.8407428 }, and there's no reason for using xsd_string.
  • Paired values for language tags

JSN3

  {            
    "@prefix": {
      "foaf:": "http://xmlns.com/foaf/0.1/",
      "xsd:": "http://www.w3.org/2001/XMLSchema#",
      "vcard:": "http://www.w3.org/2006/vcard/ns#",     
      "rdfs:": "http://www.w3.org/2000/01/rdf-schema#",
      "iCollide:": "http://example.org/icollide#"
      ":": "http://example/"
    },            
    "http://jondoe.example.org/#me": {
      "a": "foaf:Person",
      "foaf:name": "Jon",
      "iCollide:name": "Jon",
      "foaf:depiction": "http://jondoe.example.org/me.jpg",
      "foaf:knows": [[
          "http://janedoe.example.org/#me",
          {"foaf:name": "John Smith"}
      ]],                  
      "foaf:birthday": {
        "^^xsd:dateTime": "2010-03-23T13:40:22.489+00:00"
      },
      "foaf:age": 1,
      "foaf:description": [
        {
          "@en": "Just another Jon Doe"
        },
        {
          "@fr": "Justement un autre Jon Doe"
        }
      ],
      "vcard:geo": {
        "vcard:latitude": {
          "xsd:float": "49.0202626"
        },
        "vcard:longitude": {
          "xsd:float": "12.8407428"
        }
      },
      "vcard:tel": {
        "xsd:string": "+49-12-3546789"
      }
    },           
    "http://janedoe.example.org/#me": {
      "a": "foaf:Person"
    }
  }
           

Remarks:

  • Concept of namespaces and base
  • Subject is an object key
  • Data type arcs for data types
  • Language tag arcs for language tags

JSON-LD (CURIEs)

{
  "#": 
  {
    "#base": "http://example/",                
    "foaf": "http://xmlns.com/foaf/0.1/",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "vcard": "http://www.w3.org/2006/vcard/ns#",     
    "iCollide": "http://example.org/icollide#"
  },
  "@": "<http://jondoe.example.org/#me>",
  "a": "<foaf:Person>",
  "foaf:name": "Jon",
  "iCollide:name": "Jon",
  "foaf:depiction": "<http://jondoe.example.org/me.jpg>",
  "foaf:knows": 
  [
    {
      "@": "<http://janedoe.example.org/#me>",
      "a": "<foaf:Person>"
    },
    {
      "@": "<_:b0>",
      "foaf:name": "John Smith"
    }
  ],
  "foaf:birthday": "2010-03-23T13:40:22.489+00:00^^<xsd:dateTime>",
  "foaf:age": 1,
  "foaf:description": 
  [
    "Just another Jon Doe@en",
    "Justement un autre Jon Doe@fr"
  ],
  "vcard:geo": 
  {
    "vcard:latitude": "49.0202626^^<xsd:float>",
    "vcard:longitude": "12.8407428^^<xsd:float>"
  },
  "vcard:tel": "+49-12-3546789^^<xsd:string>"
}

Remarks:

  • Concept of namespaces and base
  • Sub-graph embedding (foaf:knows -> {})
  • Microsyntax for subject (@)
  • Microsyntax for language tags
  • Microsyntax for data types

JSON-LD (terms)

{
  "#": 
  {
    "Person": "http://xmlns.com/foaf/0.1/Person",
    "name": "http://xmlns.com/foaf/0.1/name",
    "depiction": "http://xmlns.com/foaf/0.1/depiction",
    "bday": "http://xmlns.com/foaf/0.1/bday",
    "age": "http://xmlns.com/foaf/0.1/age",
    "description": "http://xmlns.com/foaf/0.1/description",
    "knows": "http://xmlns.com/foaf/0.1/knows",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "vcard": "http://www.w3.org/2006/vcard/ns#",     
    "geo": "http://www.w3.org/2006/vcard/ns#geo",     
    "latitude": "http://www.w3.org/2006/vcard/ns#latitude",     
    "logitude": "http://www.w3.org/2006/vcard/ns#longitude",     
    "tel": "http://www.w3.org/2006/vcard/ns#tel",     
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "iname": "http://example.org/icollide#name"
    "#types" 
    {
      "xsd:anyURI": ["depiction", "knows"]
      "xsd:dateTime": ["birthday"]
      "xsd:float": ["latitude", "longitude"]
    }
  },
  "@": "http://jondoe.example.org/#me",
  "a": "Person",
  "name": "Jon",
  "iname": "Jon",
  "depiction": "http://jondoe.example.org/me.jpg",
  "knows": 
  [
    {
      "@": "http://janedoe.example.org/#me",
      "a": "Person"
    },
    {
      "@": "_:b0",
      "name": "John Smith"
    }
  ],                  
  "birthday": "2010-03-23T13:40:22.489+00:00",
  "age": 1,
  "description": 
  [
    "Just another Jon Doe@en",
    "Justement un autre Jon Doe@fr"
  ],
  "geo": 
  {
    "latitude": "49.0202626",
    "longitude": "12.8407428"
  },
  "tel": "+49-12-3546789"
  },
}

Remarks:

  • Concept of keywords that expand to URIs
  • Concept of sub-graph embedding (knows -> [{}, {}])
  • Microsyntax for subject (@)
  • Microsyntax for language tags
  • No microsyntax for data types (type coercion)

JTriples

  [
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://www.w3.org/2000/01/rdf-schema#type>",
      "o": "<http://xmlns.com/foaf/0.1/Person>"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/name>",
      "o": "Jon"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://example.org/icollide#name>",
      "o": "Jon"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/depiction>",
      "o": "<http://jondoe.example.org/me.jpg>"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/knows>",
      "o": "<http://janedoe.example.org/#me>"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/knows>",
      "o": "_:b0"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/birthday>",
      "o": "\"2010-03-23T13:40:22.489+00:00\"^^<http://www.w3.org/2001/XMLSchema#dateTime>"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/age>",
      "o": 1
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/description>",
      "o": "\"Just another Jon Doe\"@en"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://xmlns.com/foaf/0.1/description>",
      "o": "\"Justement un autre Jon Doe\"@fr"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://www.w3.org/2006/vcard/ns#geo>",
      "o": "_:b1"
    },
    {
      "s": "<http://jondoe.example.org/#me>",
      "p": "<http://www.w3.org/2006/vcard/ns#tel>",
      "o": "\"+49-12-3546789\"^^http://www.w3.org/2001/XMLSchema#string>"
    },
    
    {
      "s": "_:b0",
      "p": "<http://xmlns.com/foaf/0.1/name>",
      "o": "John Smith"
    },

    {
      "s": "_:b1",
      "p": "<http://www.w3.org/2006/vcard/ns#latitude>",
      "o": "\"49.0202626\"^^<http://www.w3.org/2001/XMLSchema#float>"
    },
    {
      "s": "_:b1",
      "p": "<http://www.w3.org/2006/vcard/ns#longitude>",
      "o": "\"12.8407428\"^^<http://www.w3.org/2001/XMLSchema#float>"
    },
    
    {
      "s": "<http://janedoe.example.org/#me>",
      "p": "<http://www.w3.org/2000/01/rdf-schema#type>",
      "o": "<http://xmlns.com/foaf/0.1/Person>"
    }
  ]              

Remarks:

  • No concept of namespaces
  • Microsyntax for language tags (with escaped quotes (\"))
  • Microsyntax for data types (with escaped quotes (\"))

RDF/JSON

  {                
    "http://jondoe.example.org/#me": {
      "http://www.w3.org/2000/01/rdf-schema#type": [
        {
          "value": "http://xmlns.com/foaf/0.1/Person",
          "type": "uri"
        }
      ],
      "http://xmlns.com/foaf/0.1/name": [
        {
          "value": "Jon",
          "type": "literal"
        }
      ],
      "http://example.org/icollide#name": [
        {
          "value": "Jon",
          "type": "literal"
        }
      ],
      "http://xmlns.com/foaf/0.1/depiction": [
        {
          "value": "http://jondoe.example.org/me.jpg",
          "type": "uri"
        }
      ],
      "http://xmlns.com/foaf/0.1/knows": [
        {
          "value": "http://janedoe.example.org/#me",
          "type": "uri"
        },
        {
          "value": "_:b0",
          "type": "_bnode"
        }
      ],                  
      "http://xmlns.com/foaf/0.1/birthday": [
        {
          "value": "2010-03-23T13:40:22.489+00:00",
          "type": "literal",
          "datatype": "http://www.w3.org/2001/XMLSchema#dateTime"
        }
      ],
      "http://xmlns.com/foaf/0.1/age": [
        {
          "value": 1,
          "type": "literal"
        }
      ],
      "http://xmlns.com/foaf/0.1/description": [
        {
          "value": "Just another Jon Doe",
          "type": "literal",
          "lang": "en"
        },
        {
          "value": "Justement un autre Jon Doe",
          "type": "literal",                      
          "lang": "fr"
        }
      ],
      "http://www.w3.org/2006/vcard/ns#geo": [
        {
          "value": "_:b1",
          "type": "bnode"
        }
      ],                  
      "http://www.w3.org/2006/vcard/ns#tel": [
        {
          "value": "+49-12-3546789",
          "type": "literal",
          "datatype": "http://www.w3.org/2001/XMLSchema#dateTime"
        }
      ]
    }
  }
                            
  {
    "http://janedoe.example.org/#me": {
      "http://www.w3.org/2000/01/rdf-schema#type": [
        {
          "value": "http://xmlns.com/foaf/0.1/Person",
          "type": "uri"
        }
      ]
    }
  }
  
  {
    "_:b0": {
    "http://xmlns.com/foaf/0.1/name": [
      {
        "value": "John Smith",
        "type": "literal"
      }
    ]
  }
  
  {
    "_:b1": {
      "http://www.w3.org/2006/vcard/ns#latitude": [
        {
          "value": "49.0202626",
          "type": "literal",
          "datatype": "http://www.w3.org/2001/XMLSchema#dateTime#float"
        }
      ],
      "http://www.w3.org/2006/vcard/ns#longitude": [
        {
          "value": "12.8407428",
          "type": "literal",
          "datatype": "http://www.w3.org/2001/XMLSchema#dateTime#float"
        }
      ]
    }
  }              

Remarks:

  • No concept of namespaces, full IRIs as object keys
  • Paired values for language tags
  • Paired values for data types
  • Subject as object key

RDFj

  {
    "context": {
      "base": "<http://example/>",                
      "token": {
        "name": "http://xmlns.com/foaf/0.1/name",
        "depiction": "http://xmlns.com/foaf/0.1/depiction",
        "knows": "http://xmlns.com/foaf/0.1/knows",                    
        "birthday": "http://xmlns.com/foaf/0.1/birthday",
        "age": "http://xmlns.com/foaf/0.1/age",                    
        "description": "http://xmlns.com/foaf/0.1/description",                    
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "geo": "http://www.w3.org/2006/vcard/ns#geo",     
        "tel": "http://www.w3.org/2006/vcard/ns#tel",     
        "nameICollide": "http://example.org/icollide#name"
      }
    },            
    "$" :"&<http://jondoe.example.org/#me>",
    "a": "foaf:Person",
    "name": "Jon",
    "nameICollide": "Jon",
    "depiction": "<http://jondoe.example.org/me.jpg>",
    "knows": [
      "<http://janedoe.example.org/#me>",
      "<bnode:b0>"
    ],
    "birthday": "2010-03-23T13:40:22.489+00:00^^http://www.w3.org/2001/XMLSchema#dateTime",
    "age": 1,
    "description": [
      "Just another Jon Doe@en",
      "Justement un autre Jon Doe@fr"
    ],
    "geo": {
      "latitude": {
        "context": {
          "base": "<http://example/>",                
          "token": {
            "latitude": "http://www.w3.org/2006/vcard/ns#latitude",     
            "longitude": "http://www.w3.org/2006/vcard/ns#longitude"     
          }
        },
        "$": "<>",
        "latitude": "49.0202626^^http://www.w3.org/2001/XMLSchema#float",
        "longitude": "12.8407428^^http://www.w3.org/2001/XMLSchema#float"                    
      }
    },
    "tel": "+49-12-3546789^^http://www.w3.org/2001/XMLSchema#string"
  }
  
  {
    "$": "http://janedoe.example.org/#me",
    "a": "foaf:Person"
  }
  
  {
    "context": {
      "name": "http://xmlns.com/foaf/0.1/name"
    },
    "$": "bnode:b0",
    "name": "John Smith"
  }

Remarks:

  • Concept of namespaces and base in form of namespaced tokens
  • Microsyntax for language tags
  • Microsyntax for data types
  • Microsyntax for subject ($)

SPARQL Query Results in JSON

  {
    "head": {
      "vars": [
        "name",
        "depiction",
        "knows",
        "birthday",
        "age",
        "description",
        "xsd",
        "geo",
        "tel",
        "nameICollide"                  
      ]
    },
    "results": { 
      "bindings": [
        {
          "name": {
            "type": "literal",
            "value": "Jon"                        
          },
          "nameICollide": {
            "type": "literal",
            "value": "Jon"
          },
          "depiction": {
            "type": "uri",
            "value": "http://jondoe.example.org/me.jpg"
          },
          "knows": {
            "type": "uri",
            "value": "http://janedoe.example.org/#me"
          },
          "knows": {
            "type": "bnode",
            "value": "b1"
          },
          "birthday": {
            "type": "typed-literal",
            "value": "2010-03-23T13:40:22.489+00:00",
            "datatype": "http://www.w3.org/2001/XMLSchema#dateTime"                        
          },
          "age": {
            "type": "literal",
            "value": 1
          },
          "description": {
            "type": "literal",
            "value": "Just another Jon Doe",
            "xml:lang": "en"
          },
          "description": {
            "type": "literal",
            "value": "Justement un autre Jon Doe",
            "xml:lang": "fr"                        
          },
          "geo": {
            "type": "bnode",
            "value": "b2"
          },
          "tel": {
            "type": "typed-literal",
            "value": "+49-12-3546789",
            "datatype": "http://www.w3.org/2001/XMLSchema#string"                        
          }
        }
      ]
    }
  }                  

Remarks:

  • No concept of namespaces, but un-namespaces tokens
  • No support for lists
  • Paired values for language tags
  • Paired values for data types

Flat triples approach to RDF graphs in JSON

          
  {
    "triples": [
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://www.w3.org/2000/01/rdf-schema#type"
        },
        "object": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/Person"
        }
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/name"
        }, 
        "object": {
          "type": "literal",
          "value": "Jon"
        } 
      },
      {
        "subject":  {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate":  {
          "type": "uri",
          "value": "http://example.org/icollide#name"
        },
        "object":  {
          "type": "literal",
          "value": "Jon"
        }
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/depiction"
        },
        "object": {
          "type": "uri",
          "value": "http://jondoe.example.org/me.jpg"
        }
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/knows"
        },
        "object": {
          "type": "uri",
          "value": "http://janedoe.example.org/#me"
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/knows"
        } ,
        "object": {
          "type": "bnode",
          "value": "_:b0"
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/birthday"
        },
        "object": {
          "type": "typed-literal",
          "value": "2010-03-23T13:40:22.489+00:00",
          "datatype": "http://www.w3.org/2001/XMLSchema#dateTime"
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/age"
        },
        "object": {
          "type": "literal",
          "value": 1
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/description"
        },
        "object": {
          "type": "literal",
          "value": "Just another Jon Doe",
          "xml:lang": "en"
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/description"
        },
        "object": {
          "type": "literal",
          "value": "Justement un autre Jon Doe",
          "xml:lang": "fr"
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://www.w3.org/2006/vcard/ns#geo"
        } ,
        "object": {
          "type": "bnode",
          "value": "_:b1"
        } 
      },
      {
        "subject": {
          "type": "uri",
          "value": "http://jondoe.example.org/#me"
        } ,
        "predicate": {
          "type": "uri",
          "value": "http://www.w3.org/2006/vcard/ns#tel"
        } ,
        "object": {
          "type": "typed-literal",
          "value": "+49-12-3546789",
          "datatype": "http://www.w3.org/2001/XMLSchema#string"
        } 
      },

      {
        "subject": {
          "type": "bnode",
          "value": "_:b0"
        } ,
        "predicate": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/name"
        } ,
        "object": {
          "type": "literal",
          "value": "John Smith"
        } 
      },

      {
        "subject": {
          "type": "bnode",
          "value": "_:b1"
        } ,
        "predicate": {
          "type": "uri",
          "value": "http://www.w3.org/2006/vcard/ns#latitude"
        } ,
        "object": {
          "type": "typed-literal",
          "value": "49.0202626",
          "datatype": "http://www.w3.org/2001/XMLSchema#float"
        } 
      },
      {
        "subject": {
          "type": "bnode",
          "value": "_:b1"
        } ,
        "predicate": {
          "type": "uri",
          "value": "http://www.w3.org/2006/vcard/ns#longitude"
        },
        "object": {
          "type": "typed-literal",
          "value": "12.8407428",
          "datatype": "http://www.w3.org/2001/XMLSchema#float"
        } 
      },

      {
        "subject": {
          "type": "uri",
          "value": "http://janedoe.example.org/#me"
        },
        "predicate": {
          "type": "uri",
          "value": "http://www.w3.org/2000/01/rdf-schema#type"
        } ,
        "object": {
          "type": "uri",
          "value": "http://xmlns.com/foaf/0.1/Person"
        } 
      }
    ]
  }

Remarks:

  • No concept of namespaces, but subject, predicate, object sub-objects
  • Paired values for language tags
  • Paired values for data types