Despite its original XML syntax, the RDF data model is not aligned with existing Web formats: HTML (XML), JSON.
A revision of the RDF/XML syntax was designed to appeal to Web developers.
It didn't.
One possible reason for this lack of adoption is the lack of idiomatic representations of RDF data in object-oriented programming languages.
The gap between objects and triples is "too wide"...
...despite numerous object-triple mapping libraries (Ledvinka, 2018)
In addition, Web developers typically build "full-stack" applications, including a front-end, a back-end and communication between the two.
They don't particularly need to expose data in an interoperable way (i.e. with URIs everywhere).
But full-stack Web applications are not the only kind of Web app.
On the Linked Open Data (LOD) cloud, the effort is split:
RDF can help redistribute the effort between client and server applications on the Web.
Two technologies (among others) tend towards that objective:
JSON: JavaScript Object Notation
JSON values can be objects, arrays or simple values.
Type | Example |
---|---|
Null | null |
Boolean | true , false |
Number | 2.4 |
String | "abc" |
Object | { "a": 2.4, "b": "abc", ... } |
Array | [ 2.4, "abc", ... ] |
"That’s it. That is all of JSON." — Douglas Crockford (Crockford, 2008)
Objects (in Java, Python, C#, etc.) can easily be (de)serialized in JSON.
RDF-based applications often require a transformation from/to objects.
↪ Can there be a standard JSON serialization of RDF?
JSON-LD: JSON for Linked Data
A JSON-LD document has (at least) two forms:
Try the JSON-LD Playground to process all forms of JSON-LD.
A JSON-LD object can be:
@id
)@value
)
In its compacted form, a JSON-LD document has a context
(with key @context
).
A JSON-LD context maps arbitrary JSON strings to IRIs.
A JSON-LD context includes several kinds of definitions.
See section 6 "Advanced concepts" of the JSON-LD W3C specification.
Compact IRIs: instead of full IRIs, JSON object keys can map to IRIs compacted with a declared prefix.
{
"@context": {
"dc": "http://purl.org/dc/terms/",
"mTitle": "dc:title",
"mPublisher": "dc:publisher"
}
}
Typed Values: a default datatype range can be given to JSON object keys.
{
"@context": {
"dc": "http://purl.org/dc/terms/",
"mIssued": {
"@id": "dc:issued",
"@type": "http://www.w3.org/2001/XMLSchema#date"
}
}
}
Type Coercion: a JSON string can map to a string literal or to an IRI.
{
"@context": {
"foaf": "http://xmlns.com/foaf/0.1/",
"mPrimarySubjectOf": {
"@id": "foaf:primarySubjectOf",
"@type": "@id"
}
}
}
Sets and Lists: JSON arrays can map to unordered sets of triples or to RDF lists.
{
"@context": {
"frbr": "http://vocab.org/frbr/core#",
"mEmbodiments": {
"@id": "frbr:embodiment",
"@container": "@set"
}
}
Schema.org is a collection of RDF classes and properties to describe entities typically described in Web pages.
Schema.org also provides a default JSON-LD context for Web developers to use.
JSON-LD data can be embedded in any Web page...
...including this one. To embed data:
<script>
element"type"="application/ld+json"
Schema.org annotations are everywhere on the Web.
E.g. on Rotten Tomatoes.
But not on Google or Amazon websites.
Web developers have tools for testing their schema.org annotations:
Other Web annotations framework have got lesser attention but pursue the same goal:
JSON-LD, Schema.org and, to a lesser extent, RDFa and Microdata are present in:
HTTP Archive's dataset is based on user browsing habits whereas Web Data Commons is based on pure hypermedia navigation, hence some discrepancy between the two.