JSON-LD and MongoDB

Gregg Kellogg
Gregg KelloggSemi-retired Linked Data Consultant
JSON-LD and
  MongoDB
Powering Linked Web Apps



    Gregg Kellogg
  gregg@greggkellogg.net
        @gkellogg
JSON-LD and Mongo

• JSON-LD – graph expression in JSON
• MongoDB – easily query JSON documents
• Together – efficient graph query optimized
  for client-side processing
Use Case
• WebApps: Single Page Applications (SPAS)
  • Use JSON as native object representation
  • REST access to web service mirroring
    objects
  • MongoDB document store maintaining
    equivalent object representations
• Data is linked, internally and externally (RDF)
JSON-LD
                                         @graph
   @context
                         @id

    JSON-based syntax to express linked data

                                        @language
        @value

                               @list
                                       @vocab
@type             @set
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],
    "name": "Call of Duty: Black Ops",
    "publisher": [
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                  Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],
    "name": "Call of Duty: Black Ops",
    "publisher": [
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                  Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                            Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],
    "name": "Call of Duty: Black Ops",
    "publisher": [
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                  Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                            Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",                   Type same as rdf:type
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],
    "name": "Call of Duty: Black Ops",
    "publisher": [
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                  Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                            Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",                   Type same as rdf:type
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],                                                       Data-typed values
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],
    "name": "Call of Duty: Black Ops",
    "publisher": [
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                  Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                            Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",                   Type same as rdf:type
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],                                                       Data-typed values
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],                      Simple string values
    "name": "Call of Duty: Black Ops",
    "publisher": [
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                    Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                              Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",                      Type same as rdf:type
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],                                                         Data-typed values
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],                        Simple string values
    "name": "Call of Duty: Black Ops",
    "publisher": [                                         (unordered) arrays of values
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                          Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                                    Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",                            Type same as rdf:type
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],                                                                Data-typed values
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],                               Simple string values
    "name": "Call of Duty: Black Ops",
    "publisher": [                                               (unordered) arrays of values
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],                                                     subject reference links to other resources
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON, as expected
{
    "@context": "/contexts/wikia.jsonld",                          Context defines terms
    "@id": "500f1a1b6e7f1827ba000001",
    "@type": "wikia:VideoGame",                                    Identifier treated as IRI
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",
       "PEGI: 18+ (DS version is 16+) ",                            Type same as rdf:type
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],                                                                Data-typed values
    "datePublished": "2011-11-09",
    "description": "Primary game entry point",
    "genre": ["First-person shooter"],                               Simple string values
    "name": "Call of Duty: Black Ops",
    "publisher": [                                               (unordered) arrays of values
       {"@id": "501067246e7f184553000001"},
       {"@id": "5010675a6e7f18464d000001"}
    ],                                                     subject reference links to other resources
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",                           Arrays may be ordered in @context
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
JSON-LD context
{
    "@context": "/contexts/wikia.jsonld",                  {
    "@id": "500f1a1b6e7f1827ba000001",                         "@context": {
    "@type": "wikia:VideoGame",                                 "wikia":     "http://data.wikia.com/terms#",
    "contentRating": [                                          "xsd":      "http://www.w3.org/2001/XMLSchema#",
       "ESRB: Mature (DS version is Teen)",                     "@vocab":      "http://schema.org/",
       "PEGI: 18+ (DS version is 16+) ",                        "@language": "en",
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"
    ],                                                             "dateCreated": {"@type": "xsd:dateTime"},
    "datePublished": "2011-11-09",                                 "dateModified": {"@type": "xsd:dateTime"},
    "description": "Primary game entry point",                     "event":       {"@id": "wikia:event",
    "genre": ["First-person shooter"],                                             "@type": "@id",
    "name": "Call of Duty: Black Ops",                                             "@container": "@list"},
    "publisher": [                                                 "startDate":   {"@type": "xsd:dateTime"},
       {"@id": "501067246e7f184553000001"},                        "width":       {"@type": "xsd:integer"}
       {"@id": "5010675a6e7f18464d000001"}                     }
    ],                                                     }
    "event": [
       "500f28856e7f187196000001",
       "500f44556e7f18f7ef000001",
       "500f449e6e7f18f94b000001",
       "500f44e26e7f18fa75000001"
    ],
    "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"]
}
Syntactic Conventions

• Keys represent unique properties
• Values may be singular or multiple
 • May use strings for most value
    representations, with typing information
    maintained in a context.
Unique properties
                 {
Expanded Form:       "http://schema.org/publisher": [
                       {"@id": "501067246e7f184553000001"},
                       {"@id": "5010675a6e7f18464d000001"}
                     ]
                 }


                 {

Compact Form:        "publisher": [
                       "501067246e7f184553000001",
                       "5010675a6e7f18464d000001"
                     ]
                 }
Context:
                 {
                     "@context": {
                       "@vocab": "http://schema.org/",
                       "publisher":{"@type": "@id"},
                       ...
                     }
                 }
Language tagged values
                 {
Expanded Form:       "http://schema.org/name": {
                       "@value": "Call of Duty: Black Ops",
                       "@language": "en"
                     }
                 }




Compact Form:    { "name": "Call of Duty: Black Ops" }




Context:         {
                     "@context": {
                       "@vocab": "http://schema.org/",
                       "@language": "en",
                       ...
                     }
                 }
Typed values
                 {
Expanded Form:       "http://schema.org/datePublished": {
                       "@value": "2011-11-09",
                       "@type": "xsd:dateTime"
                     }
                 }




Compact Form:    { "datePublished": "2011-11-09" }



                 {
Context:             "@context": {
                       "@vocab": "http://schema.org/",
                       "xsd": "http://www.w3.org/2001/XMLSchema#",
                       "datePublished":{"@type": "xsd:dateTime"},
                       ...
                     }
                 }
Subject references
                 {
Expanded Form:       "http://schema.org/publisher": [
                       {"@id": "501067246e7f184553000001"},
                       {"@id": "5010675a6e7f18464d000001"}
                     ]
                 }


                 {

Compact Form:        "publisher": [
                       "501067246e7f184553000001",
                       "5010675a6e7f18464d000001"
                     ]
                 }
Context:
                 {
                     "@context": {
                       "@vocab": "http://schema.org/",
                       "publisher":{"@type": "@id"},
                       ...
                     }
                 }
Nesting
     Flattened Form                                                    Nested Form:
{                                                               {
    "@context": "/contexts/wikia.jsonld",                           "@context": "/contexts/wikia.jsonld",
    "@graph": [                                                     "@id": "500f1a1b6e7f1827ba000001",
      {                                                             "@type": "wikia:VideoGame",
        "@id": "500f1a1b6e7f1827ba000001",                          "name": "Call of Duty: Black Ops",
        "@type": "wikia:VideoGame",                                 "publisher": [
        "name": "Call of Duty: Black Ops",                            {
        "publisher": [                                                  "@id": "501067246e7f184553000001",
           "501067246e7f184553000001",                                  "name": "Activision",
           "5010675a6e7f18464d000001"                                   "url": "http://callofduty.wikia.com/wiki/Activision",
        ]                                                               "@type": "schema:Corporation"
      }, {                                                            }, {
        "@id": "501067246e7f184553000001",                              "@id": "5010675a6e7f18464d000001",
        "name": "Activision",                                           "@type": "schema:Corporation",
        "url": "http://callofduty.wikia.com/wiki/Activision",           "name": "Square Enix (Japan)"
        "@type": "schema:Corporation"                                 }
      }, {                                                          ]
        "@id": "5010675a6e7f18464d000001",                      }
        "@type": "schema:Corporation",
        "name": "Square Enix (Japan)"
      }
    ]
}
Nesting
     Flattened Form                                                    Nested Form:
{                                                               {
    "@context": "/contexts/wikia.jsonld",                           "@context": "/contexts/wikia.jsonld",
    "@graph": [                                                     "@id": "500f1a1b6e7f1827ba000001",
      {                                                             "@type": "wikia:VideoGame",
        "@id": "500f1a1b6e7f1827ba000001",                          "name": "Call of Duty: Black Ops",
        "@type": "wikia:VideoGame",                                 "publisher": [
        "name": "Call of Duty: Black Ops",                            {
        "publisher": [                                                  "@id": "501067246e7f184553000001",
           "501067246e7f184553000001",                                  "name": "Activision",
           "5010675a6e7f18464d000001"                                   "url": "http://callofduty.wikia.com/wiki/Activision",
        ]                                                               "@type": "schema:Corporation"
      }, {                                                            }, {
        "@id": "501067246e7f184553000001",                              "@id": "5010675a6e7f18464d000001",
        "name": "Activision",                                           "@type": "schema:Corporation",
        "url": "http://callofduty.wikia.com/wiki/Activision",           "name": "Square Enix (Japan)"
        "@type": "schema:Corporation"                                 }
      }, {                                                          ]
        "@id": "5010675a6e7f18464d000001",                      }
        "@type": "schema:Corporation",
        "name": "Square Enix (Japan)"
      }
    ]
}
Nesting
     Flattened Form                                                    Nested Form:
{                                                               {
    "@context": "/contexts/wikia.jsonld",                           "@context": "/contexts/wikia.jsonld",
    "@graph": [                                                     "@id": "500f1a1b6e7f1827ba000001",
      {                                                             "@type": "wikia:VideoGame",
        "@id": "500f1a1b6e7f1827ba000001",                          "name": "Call of Duty: Black Ops",
        "@type": "wikia:VideoGame",                                 "publisher": [
        "name": "Call of Duty: Black Ops",                            {
        "publisher": [                                                  "@id": "501067246e7f184553000001",
           "501067246e7f184553000001",                                  "name": "Activision",
           "5010675a6e7f18464d000001"                                   "url": "http://callofduty.wikia.com/wiki/Activision",
        ]                                                               "@type": "schema:Corporation"
      }, {                                                            }, {
        "@id": "501067246e7f184553000001",                              "@id": "5010675a6e7f18464d000001",
        "name": "Activision",                                           "@type": "schema:Corporation",
        "url": "http://callofduty.wikia.com/wiki/Activision",           "name": "Square Enix (Japan)"
        "@type": "schema:Corporation"                                 }
      }, {                                                          ]
        "@id": "5010675a6e7f18464d000001",                      }
        "@type": "schema:Corporation",
        "name": "Square Enix (Japan)"
      }
    ]
}
In-memory linking
     Flattened Form                                 Linked Form:
{
     "@id": "500f1a1b6e7f1827ba000001",          @id         500f1a1b6e7f1827ba000001
     "type": "wikia:VideoGame",
     "schema:name": "Call of Duty: Black Ops",   type        wikia:VideoGame
     "wikia:event": [
       {"@id": "500f28856e7f187196000001"},      name        "Call of Duty: Black Ops"
       {"@id": "500f44556e7f18f7ef000001"},      event       500f28856e7f187196000001
       {"@id": "500f449e6e7f18f94b000001"},
       {"@id": "500f44e26e7f18fa75000001"}
     ]
},
{                                                @id         500f28856e7f187196000001
     "@id": "500f28856e7f187196000001",
                                                 type        cod:Mission
     "type": "cod:Mission",
     "schema:name": "Operation 40",              name        "Operation 40"
     "schema:startDate": "1961-04-17",           startDate   "1961-04-17"
     "wikia:eventIn": [
       {"@id": "500f1a1b6e7f1827ba000001"}       event       500f1a1b6e7f1827ba000001
     ]
}
Turtle Mapping
{                                                        @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    "@context": "/contexts/wikia.jsonld",                @prefix schema: <http://schema.org/> .
    "@id": "500f1a1b6e7f1827ba000001",                   @prefix wikia: <http://data.wikia.com/terms#> .
    "@type": "wikia:VideoGame",                          @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    "contentRating": [
       "ESRB: Mature (DS version is Teen)",              <500f1a1b6e7f1827ba000001> a wikia:VideoGame;
       "PEGI: 18+ (DS version is 16+) ",                    schema:contentRating "ESRB: Mature (DS version is Teen)"@en,
       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"       "PEGI: 18+ (DS version is 16+) "@en,
    ],                                                       "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"@en;
    "datePublished": "2011-11-09",                          schema:datePublished: "2011-11-09"^^xsd:dateTime;
    "name": "Call of Duty: Black Ops",                      schema:name "Call of Duty: Black Ops"@en;
    "publisher": [                                          schema:publisher <501067246e7f184553000001>,
       {"@id": "501067246e7f184553000001"},                  <5010675a6e7f18464d000001> .
       {"@id": "5010675a6e7f18464d000001"}                  wikia:event <500f28856e7f187196000001>,
    ],                                                       ...;
    "wikia:event": [                                      .
       {"@id": "500f28856e7f187196000001"},
       ...
    ]
}
More JSON-LD Features*

  • @set, @list,                                  • Embedded
        Compact IRIs,                              @context
        Unlabeled Nodes                            definitions

  • Language maps                                 • Named Graphs
  • Property generators


* http://json-ld.org/spec/latest/json-ld-syntax
History

•   2009 – Started as a way to project from the RDFa API

    •   Developers want solutions to work within HTML
        applications

    •   Desire for JSON-idiomatic way of representing RDF
        (Linked Data)

    •   Adapt existing JSON APIs to Linked Data
History

• 2011 – W3C Community Group launched
 • Broad Participation
 • Separation of Syntax from API
 • Proposed to W3C RDF 1.1 Working
   Group
History
• 2012 – RDF WG abandons other JSON
  serialization efforts (RDF/JSON)
 • JSON-LD accepted as official work item
 • Community Group drafts final report
 • RDF WG publishes JSON-LD (Syntax and
    API) as FPWD
MongoDB
• JSON-like document store
 • BSON supports extra datatypes
 • Certain key patterns are restricted
    • e.g., “.” not allowed in a key
• Query on value = pattern or value includes
  pattern
Use Case
Wikia Structured Data API
Wikia Application
• Express Wiki content as structured data
  • Wiki markup doesn’t naturally include
    semantic cues (Semantic Media Wiki
    aside).
• Add semantic markup to HTML generated
  from Wikis in RDFa
• Aggregate structured content through
  JSON-LD/MongoDB powered data service
Service Architecture
• MongoDB persistence
• JSON document representation
 • JSON-LD describedby link header
• Ruby/Sinatra web service
 • Content-negotiated access to data
    • JSON-LD, HTML, Turtle, ...
Document Model

                               {
•   Use aliases for @id and        "id": "500f1a1b6e7f1827ba000001",
                                   "type": "wikia:VideoGame",
    @type keywords                 "name": "Call of Duty: Black Ops",
                                   "publisher": [

    •   Simplifies use within          "501067246e7f184553000001",
                                      "5010675a6e7f18464d000001"
        client-side MVC            ],
                                   "wikia:event": [
        frameworks (e.g.             "500f28856e7f187196000001"
        backbone.js)               ]
                               }
Document Model

                         {
                             "id": "500f1a1b6e7f1827ba000001",
                             "type": "wikia:VideoGame",
                             "name": "Call of Duty: Black Ops",
•   Individual subject       "publisher": [
                                "501067246e7f184553000001",
    definition as Mongo          "5010675a6e7f18464d000001"
    document                 ],
                             "wikia:event": [
                                "500f28856e7f187196000001"
                             ]
                         }
Document Model

                               {
                                   "id": "500f1a1b6e7f1827ba000001",

•   Use expanded subject           "type": "wikia:VideoGame",
                                   "name": "Call of Duty: Black Ops",
    references                     "publisher": [
                                      {"id": "501067246e7f184553000001"},
                                      {"id": "5010675a6e7f18464d000001"}
    ➡This allows simple            ],
                                   "wikia:event": [
      traversal for graphify          {"id": "500f28856e7f187196000001"}
                                   ]
                               }
Document Model
                             {
                                 "id": "500f1a1b6e7f1827ba000001",

•
                                 "type": "wikia:VideoGame",
    Gather subject               "name": "Call of Duty: Black Ops",
                                 "publisher": [
    references under a              {"id": "501067246e7f184553000001"},
    hidden key                      {"id": "5010675a6e7f18464d000001"}
                                 ],
                                 "wikia:event": [
    ➡This allows easy            ],
                                    {"id": "500f28856e7f187196000001"}
      querying for objects       "_references": [
      referencing another           "501067246e7f184553000001",
                                    "5010675a6e7f18464d000001",
      object                        "500f28856e7f187196000001"
                                 ]
                             }
Document Model
                             GET http://example.com/collection/
                             500f1a1b6e7f1827ba000001

                             HTTP/1.1 200 OK
                             Content-Type: application/json;charset=utf-8
                             Link: </contexts/wikia.jsonld>; rel="describedby";
                             type="application/ld+json"

•   Return context as HTTP   {
    Link Header                  "id": "500f1a1b6e7f1827ba000001",
                                 "type": "wikia:VideoGame",
                                 "name": "Call of Duty: Black Ops",
                                 "publisher": [
                                    {"id": "501067246e7f184553000001"},
                                    {"id": "5010675a6e7f18464d000001"}
                                 ],
                                 "wikia:event": [
                                    {"id": "500f28856e7f187196000001"}
                                 ]
                             }
Restful Endpoints
                               GET http://example.com/collection/?
                               withType="schema:Corporation"
                               Accept: application/json

                               HTTP/1.1 200 OK
•   index – query collection   Content-Type: application/json;charset=utf-8
                               Link: </contexts/wikia.jsonld>; rel="describedby";
                               type="application/ld+json"
    •   by type – return       [
        objects having (or         {
        containing) a type           "id": "501067246e7f184553000001",
                                     "type": "schema:Corporation",
                                     "name": "Activision",
                                     "url": "http://callofduty.wikia.com/wiki/Activision"
                                   }, {
                                     "id": "5010675a6e7f18464d000001",
                                     "type": "schema:Corporation",
                                     "name": "Square Enix (Japan)"
                                   }
                               ]
Restful Endpoints
•
                               GET http://example.com/collection/?
    index – query collection   referencing="500f1a1b6e7f1827ba000001"
                               Accept: application/json

    •   by referencing –       HTTP/1.1 200 OK
        return objects         Content-Type: application/json;charset=utf-8
                               Link: </contexts/wikia.jsonld>; rel="describedby";
        referencing another    type="application/ld+json"
        object                 [{
                                 "id": "500f28856e7f187196000001",

    •   Build out space          "cod:game": {"id": "500f1a1b6e7f1827ba000001"},
                                 "schema:name": "Operation 40",
        around an object         "schema:startDate": "1961-04-17T00:00:00",
                                 "wikia:eventIn": [{"id": "500f1a1b6e7f1827ba000001"}],
                                 "wikia:next": {"id": "500f44556e7f18f7ef000001"},

    •   Similar to SPARQL        "wikia:objective": [
                                    {"id": "501445266e7f1847c6000001"},
        describe                    {"id": "50143e1e6e7f18256d000001"},
                                    ...
                                 ],
                               }, ...]
Restful Endpoints
                          GET http://example.com/collection/
                          500f1a1b6e7f1827ba000001
                          Accept: application/json

                          HTTP/1.1 200 OK
                          Content-Type: application/json;charset=utf-8
                          Link: </contexts/wikia.jsonld>; rel="describedby";

•
                          type="application/ld+json"
    GET – return single
                          {
    object                    "id": "500f1a1b6e7f1827ba000001",
                              "type": "wikia:VideoGame",
                              "name": "Call of Duty: Black Ops",
                              "publisher": [
                                {"id": "501067246e7f184553000001"},
                                {"id": "5010675a6e7f18464d000001"}
                              ]
                          }
Restful Endpoints
                               POST http://example.com/collection/
                               Accept: application/json
                               Content-Type: application/json

                               {

•   POST – Create new              "type": "wikia:VideoGame",
                                   "name": "Call of Duty: Black Ops"
    object                     }
                               HTTP/1.1 201 Created

    •
                               Content-Type: application/json;charset=utf-8
        Good practice to       Link: </contexts/wikia.jsonld>; rel="describedby";
                               type="application/ld+json"
        maintain dateCreated   Location: http://example.com/collection/
        and dateModified        500f1a1b6e7f1827ba000001

        equivalents            {
                                   "id": "500f1a1b6e7f1827ba000001",
                                   "type": "wikia:VideoGame",
                                   "name": "Call of Duty: Black Ops",
                                   "dateCreated": "2012-08-23T14:00:00-08:00",
                                   "dateModified": "2012-08-23T14:00:00-08:00",
                               }
Restful Endpoints
                             PUT http://example.com/collection/
                             500f1a1b6e7f1827ba000001
                             Accept: application/json
                             Content-Type: application/json

                             HTTP/1.1 200 OK
                             Content-Type: application/json;charset=utf-8
•   PUT – Update object      Link: </contexts/wikia.jsonld>; rel="describedby";
                             type="application/ld+json"


    •   Good practice to     {
                                 "id": "500f1a1b6e7f1827ba000001",
        update dateModified       "type": "wikia:VideoGame",
                                 "name": "Call of Duty: Black Ops",
        equivalent               "publisher": [
                                    {"id": "501067246e7f184553000001"},
                                    {"id": "5010675a6e7f18464d000001"}
                                 ],
                                 "dateCreated": "2012-08-23T14:00:00-08:00",
                                 "dateModified": "2012-08-23T14:15:00-08:00",
                             }
Restful Endpoints


                       DELETE http://example.com/collection/
•   DELETE – Destroy   500f1a1b6e7f1827ba000001

    object             HTTP/1.1 204 No Content
Restful Endpoints
                                GET http://example.com/collection/
                                500f1a1b6e7f1827ba000001/publisher/
                                Accept: application/json

                                HTTP/1.1 200 OK

•   path – relational query     Content-Type: application/json;charset=utf-8
                                Link: </contexts/wikia.jsonld>; rel="describedby";
                                type="application/ld+json"

    •   Return objects having   [
        a property                  {
                                    "id": "501067246e7f184553000001",
        relationship with           "type": "schema:Corporation",
        another object              "name": "Activision",
                                    "url": "http://callofduty.wikia.com/wiki/
                                Activision"
                                  }, {
                                    "id": "5010675a6e7f18464d000001",
                                    "type": "schema:Corporation",
                                    "name": "Square Enix (Japan)"
                                  }
                                ]
Restful Endpoints
                              GET http://example.com/collection/
                              500f1a1b6e7f1827ba000001
                              Accept: application/ld+json

                              HTTP/1.1 200 OK
                              Content-Type: application/ld+json;charset=utf-8


•   GET – as explicit JSON-   {
                                  "@context": "/contexts/wikia.jsonld",
    LD                            "id": "500f1a1b6e7f1827ba000001",
                                  "type": "wikia:VideoGame",
                                  "name": "Call of Duty: Black Ops",
                                  "publisher": [
                                    {"id": "501067246e7f184553000001"},
                                    {"id": "5010675a6e7f18464d000001"}
                                  ]
                              }
Working with data
•   Application Structure

    •   Ruby/Sinatra REST
        service

    •   JavaScript/Backbone.js
        client
                                 {
•   Alias JSON-LD                    "@context": {
                                       "id":     "@id",
    keywords for
                                       "type":     "@type"
    convenience
                                     }
                                 }
MVC Client
      • Natural access from client-side MVC (e.g.,
            backbone.js)

                                          Collection
// Object collection, handles objects constructed from OWL classes and properties.
// Initial fetch is only for VideoGame types, as referenced objects are
// fetched, they are added to the collection.
Wikia.ObjectCollection = Backbone.Collection.extend({
  initialize: function() { this.model = Wikia.ObjectModel; },
  url: function() { return "/api/#{@vers}/#{@name}"; },
  comparator: function(model) { return model.get('schema:name') }
  ...
}
MVC Client
       • Natural access from client-side MVC (e.g.,
             backbone.js)

                                                  Model
// OWL model class and sub-classes for dealing with owl:Class,
// owl:DatatypeProperty, owl:ObjectProperty and owl:Datatype
Wikia.ObjectModel Backbone.Model.extend({
  referencedObjects: function() { return this.resolve(_.flatten(_.toArray(this.attributes))); },
  getModel: function(key, options) { return this._resolve this.get(key)) },
  setModel: function(key, value) {...},
  _resolve: function(value) {...},
  ...
}
Summary
•   JSON-LD is a light-weight layer for representing
    linked data in JSON
•   The MongoDB document model is a natural fit for
    JSON-LD
    •   Not optimized for SPARQL; consider alternatives
•   Single Page Applications benefit from linked data
    principles
    •   RDF with OWL can be powerful when used
        appropriately in the client
Resources
•   JSON-LD Syntax
    •   http://w3.org/TR/json-ld-syntax
•   JSON-LD API
    •   http://w3.org/TR/json-ld-api
•   Git Repo
    •   https://github.com/json-ld/json-ld.org
•   Information/Playground
    •   http://json-ld.org/
•   IRC
    •   #json-ld on Freenode
More Information

   json-ld.org              JavaScript
                               Ruby
rdf-comments@w3.org             Python
                                  PHP
                                     Java
 Gregg Kellogg
 gregg@greggkellogg.net
 http://greggkellogg.net/
 @gkellogg
1 of 51

Recommended

Building Next-Generation Web APIs with JSON-LD and Hydra by
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraMarkus Lanthaler
42K views56 slides
JSON-LD for RESTful services by
JSON-LD for RESTful servicesJSON-LD for RESTful services
JSON-LD for RESTful servicesMarkus Lanthaler
20.8K views19 slides
JSON-LD: JSON for Linked Data by
JSON-LD: JSON for Linked DataJSON-LD: JSON for Linked Data
JSON-LD: JSON for Linked DataGregg Kellogg
73.4K views50 slides
JSON-LD: JSON for the Social Web by
JSON-LD: JSON for the Social WebJSON-LD: JSON for the Social Web
JSON-LD: JSON for the Social WebGregg Kellogg
23K views11 slides
Hydra: A Vocabulary for Hypermedia-Driven Web APIs by
Hydra: A Vocabulary for Hypermedia-Driven Web APIsHydra: A Vocabulary for Hypermedia-Driven Web APIs
Hydra: A Vocabulary for Hypermedia-Driven Web APIsMarkus Lanthaler
27.5K views17 slides
Model Your Application Domain, Not Your JSON Structures by
Model Your Application Domain, Not Your JSON StructuresModel Your Application Domain, Not Your JSON Structures
Model Your Application Domain, Not Your JSON StructuresMarkus Lanthaler
29.2K views22 slides

More Related Content

What's hot

FIWARE Global Summit - NGSI-LD - NGSI with Linked Data by
FIWARE Global Summit - NGSI-LD - NGSI with Linked DataFIWARE Global Summit - NGSI-LD - NGSI with Linked Data
FIWARE Global Summit - NGSI-LD - NGSI with Linked DataFIWARE
2.6K views35 slides
MongoDB Fundamentals by
MongoDB FundamentalsMongoDB Fundamentals
MongoDB FundamentalsMongoDB
1.8K views46 slides
2.28.17 Introducing DSpace 7 Webinar Slides by
2.28.17 Introducing DSpace 7 Webinar Slides2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar SlidesDuraSpace
1.5K views53 slides
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production by
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in ProductionKong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in ProductionFIWARE
428 views18 slides
FIWARE Training: NGSI-LD Advanced Operations by
FIWARE Training: NGSI-LD Advanced OperationsFIWARE Training: NGSI-LD Advanced Operations
FIWARE Training: NGSI-LD Advanced OperationsFIWARE
340 views34 slides
Data Modeling with NGSI, NGSI-LD by
Data Modeling with NGSI, NGSI-LDData Modeling with NGSI, NGSI-LD
Data Modeling with NGSI, NGSI-LDFernando Lopez Aguilar
1.1K views34 slides

What's hot(20)

FIWARE Global Summit - NGSI-LD - NGSI with Linked Data by FIWARE
FIWARE Global Summit - NGSI-LD - NGSI with Linked DataFIWARE Global Summit - NGSI-LD - NGSI with Linked Data
FIWARE Global Summit - NGSI-LD - NGSI with Linked Data
FIWARE2.6K views
MongoDB Fundamentals by MongoDB
MongoDB FundamentalsMongoDB Fundamentals
MongoDB Fundamentals
MongoDB1.8K views
2.28.17 Introducing DSpace 7 Webinar Slides by DuraSpace
2.28.17 Introducing DSpace 7 Webinar Slides2.28.17 Introducing DSpace 7 Webinar Slides
2.28.17 Introducing DSpace 7 Webinar Slides
DuraSpace1.5K views
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production by FIWARE
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in ProductionKong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production
Kong, Keyrock, Keycloak, i4Trust - Options to Secure FIWARE in Production
FIWARE428 views
FIWARE Training: NGSI-LD Advanced Operations by FIWARE
FIWARE Training: NGSI-LD Advanced OperationsFIWARE Training: NGSI-LD Advanced Operations
FIWARE Training: NGSI-LD Advanced Operations
FIWARE340 views
Redis + Structured Streaming—A Perfect Combination to Scale-Out Your Continuo... by Databricks
Redis + Structured Streaming—A Perfect Combination to Scale-Out Your Continuo...Redis + Structured Streaming—A Perfect Combination to Scale-Out Your Continuo...
Redis + Structured Streaming—A Perfect Combination to Scale-Out Your Continuo...
Databricks1.6K views
Airflow를 이용한 데이터 Workflow 관리 by YoungHeon (Roy) Kim
Airflow를 이용한  데이터 Workflow 관리Airflow를 이용한  데이터 Workflow 관리
Airflow를 이용한 데이터 Workflow 관리
YoungHeon (Roy) Kim9.1K views
FIWARE Training: JSON-LD and NGSI-LD by FIWARE
FIWARE Training: JSON-LD and NGSI-LDFIWARE Training: JSON-LD and NGSI-LD
FIWARE Training: JSON-LD and NGSI-LD
FIWARE96 views
Data modeling for Elasticsearch by Florian Hopf
Data modeling for ElasticsearchData modeling for Elasticsearch
Data modeling for Elasticsearch
Florian Hopf12.7K views
Mongo DB 성능최적화 전략 by Jin wook
Mongo DB 성능최적화 전략Mongo DB 성능최적화 전략
Mongo DB 성능최적화 전략
Jin wook17.6K views
Moving from SQL Server to MongoDB by Nick Court
Moving from SQL Server to MongoDBMoving from SQL Server to MongoDB
Moving from SQL Server to MongoDB
Nick Court14.4K views
Retail referencearchitecture productcatalog by MongoDB
Retail referencearchitecture productcatalogRetail referencearchitecture productcatalog
Retail referencearchitecture productcatalog
MongoDB3.6K views
Indexing with MongoDB by MongoDB
Indexing with MongoDBIndexing with MongoDB
Indexing with MongoDB
MongoDB12.6K views
날로 먹는 Django admin 활용 by KyeongMook "Kay" Cha
날로 먹는 Django admin 활용날로 먹는 Django admin 활용
날로 먹는 Django admin 활용
FIWARE Wednesday Webinars - Introduction to NGSI-LD by FIWARE
FIWARE Wednesday Webinars - Introduction to NGSI-LDFIWARE Wednesday Webinars - Introduction to NGSI-LD
FIWARE Wednesday Webinars - Introduction to NGSI-LD
FIWARE856 views
Log analysis using elk by Rushika Shah
Log analysis using elkLog analysis using elk
Log analysis using elk
Rushika Shah647 views
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록 by Jaehyeuk Oh
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
하이퍼커넥트 데이터 팀이 데이터 증가에 대처해온 기록
Jaehyeuk Oh1.6K views

Recently uploaded

Ransomware is Knocking your Door_Final.pdf by
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
59 views46 slides
Unit 1_Lecture 2_Physical Design of IoT.pdf by
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdfStephenTec
12 views36 slides
Voice Logger - Telephony Integration Solution at Aegis by
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at AegisNirmal Sharma
39 views1 slide
virtual reality.pptx by
virtual reality.pptxvirtual reality.pptx
virtual reality.pptxG036GaikwadSnehal
14 views15 slides
MVP and prioritization.pdf by
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdfrahuldharwal141
31 views8 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
38 views15 slides

Recently uploaded(20)

Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
Future of AR - Facebook Presentation by ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56115 views
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf by Dr. Jimmy Schwarzkopf
STKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdfSTKI Israeli Market Study 2023   corrected forecast 2023_24 v3.pdf
STKI Israeli Market Study 2023 corrected forecast 2023_24 v3.pdf
Data Integrity for Banking and Financial Services by Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely25 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Piloting & Scaling Successfully With Microsoft Viva by Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker40 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman36 views
Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors by sugiuralab
TouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective SensorsTouchLog: Finger Micro Gesture Recognition  Using Photo-Reflective Sensors
TouchLog: Finger Micro Gesture Recognition Using Photo-Reflective Sensors
sugiuralab21 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views

JSON-LD and MongoDB

  • 1. JSON-LD and MongoDB Powering Linked Web Apps Gregg Kellogg gregg@greggkellogg.net @gkellogg
  • 2. JSON-LD and Mongo • JSON-LD – graph expression in JSON • MongoDB – easily query JSON documents • Together – efficient graph query optimized for client-side processing
  • 3. Use Case • WebApps: Single Page Applications (SPAS) • Use JSON as native object representation • REST access to web service mirroring objects • MongoDB document store maintaining equivalent object representations • Data is linked, internally and externally (RDF)
  • 4. JSON-LD @graph @context @id JSON-based syntax to express linked data @language @value @list @vocab @type @set
  • 5. JSON, as expected { "@context": "/contexts/wikia.jsonld", "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], "name": "Call of Duty: Black Ops", "publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 6. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], "name": "Call of Duty: Black Ops", "publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 7. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], "name": "Call of Duty: Black Ops", "publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 8. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", Type same as rdf:type "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], "name": "Call of Duty: Black Ops", "publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 9. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", Type same as rdf:type "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], Data-typed values "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], "name": "Call of Duty: Black Ops", "publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 10. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", Type same as rdf:type "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], Data-typed values "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], Simple string values "name": "Call of Duty: Black Ops", "publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 11. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", Type same as rdf:type "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], Data-typed values "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], Simple string values "name": "Call of Duty: Black Ops", "publisher": [ (unordered) arrays of values {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 12. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", Type same as rdf:type "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], Data-typed values "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], Simple string values "name": "Call of Duty: Black Ops", "publisher": [ (unordered) arrays of values {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], subject reference links to other resources "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 13. JSON, as expected { "@context": "/contexts/wikia.jsonld", Context defines terms "@id": "500f1a1b6e7f1827ba000001", "@type": "wikia:VideoGame", Identifier treated as IRI "contentRating": [ "ESRB: Mature (DS version is Teen)", "PEGI: 18+ (DS version is 16+) ", Type same as rdf:type "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], Data-typed values "datePublished": "2011-11-09", "description": "Primary game entry point", "genre": ["First-person shooter"], Simple string values "name": "Call of Duty: Black Ops", "publisher": [ (unordered) arrays of values {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ], subject reference links to other resources "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", Arrays may be ordered in @context "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 14. JSON-LD context { "@context": "/contexts/wikia.jsonld", { "@id": "500f1a1b6e7f1827ba000001", "@context": { "@type": "wikia:VideoGame", "wikia": "http://data.wikia.com/terms#", "contentRating": [ "xsd": "http://www.w3.org/2001/XMLSchema#", "ESRB: Mature (DS version is Teen)", "@vocab": "http://schema.org/", "PEGI: 18+ (DS version is 16+) ", "@language": "en", "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" ], "dateCreated": {"@type": "xsd:dateTime"}, "datePublished": "2011-11-09", "dateModified": {"@type": "xsd:dateTime"}, "description": "Primary game entry point", "event": {"@id": "wikia:event", "genre": ["First-person shooter"], "@type": "@id", "name": "Call of Duty: Black Ops", "@container": "@list"}, "publisher": [ "startDate": {"@type": "xsd:dateTime"}, {"@id": "501067246e7f184553000001"}, "width": {"@type": "xsd:integer"} {"@id": "5010675a6e7f18464d000001"} } ], } "event": [ "500f28856e7f187196000001", "500f44556e7f18f7ef000001", "500f449e6e7f18f94b000001", "500f44e26e7f18fa75000001" ], "wikia:platform": ["Xbox 360","PS3","PC","Wii","DS"] }
  • 15. Syntactic Conventions • Keys represent unique properties • Values may be singular or multiple • May use strings for most value representations, with typing information maintained in a context.
  • 16. Unique properties { Expanded Form: "http://schema.org/publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ] } { Compact Form: "publisher": [ "501067246e7f184553000001", "5010675a6e7f18464d000001" ] } Context: { "@context": { "@vocab": "http://schema.org/", "publisher":{"@type": "@id"}, ... } }
  • 17. Language tagged values { Expanded Form: "http://schema.org/name": { "@value": "Call of Duty: Black Ops", "@language": "en" } } Compact Form: { "name": "Call of Duty: Black Ops" } Context: { "@context": { "@vocab": "http://schema.org/", "@language": "en", ... } }
  • 18. Typed values { Expanded Form: "http://schema.org/datePublished": { "@value": "2011-11-09", "@type": "xsd:dateTime" } } Compact Form: { "datePublished": "2011-11-09" } { Context: "@context": { "@vocab": "http://schema.org/", "xsd": "http://www.w3.org/2001/XMLSchema#", "datePublished":{"@type": "xsd:dateTime"}, ... } }
  • 19. Subject references { Expanded Form: "http://schema.org/publisher": [ {"@id": "501067246e7f184553000001"}, {"@id": "5010675a6e7f18464d000001"} ] } { Compact Form: "publisher": [ "501067246e7f184553000001", "5010675a6e7f18464d000001" ] } Context: { "@context": { "@vocab": "http://schema.org/", "publisher":{"@type": "@id"}, ... } }
  • 20. Nesting Flattened Form Nested Form: { { "@context": "/contexts/wikia.jsonld", "@context": "/contexts/wikia.jsonld", "@graph": [ "@id": "500f1a1b6e7f1827ba000001", { "@type": "wikia:VideoGame", "@id": "500f1a1b6e7f1827ba000001", "name": "Call of Duty: Black Ops", "@type": "wikia:VideoGame", "publisher": [ "name": "Call of Duty: Black Ops", { "publisher": [ "@id": "501067246e7f184553000001", "501067246e7f184553000001", "name": "Activision", "5010675a6e7f18464d000001" "url": "http://callofduty.wikia.com/wiki/Activision", ] "@type": "schema:Corporation" }, { }, { "@id": "501067246e7f184553000001", "@id": "5010675a6e7f18464d000001", "name": "Activision", "@type": "schema:Corporation", "url": "http://callofduty.wikia.com/wiki/Activision", "name": "Square Enix (Japan)" "@type": "schema:Corporation" } }, { ] "@id": "5010675a6e7f18464d000001", } "@type": "schema:Corporation", "name": "Square Enix (Japan)" } ] }
  • 21. Nesting Flattened Form Nested Form: { { "@context": "/contexts/wikia.jsonld", "@context": "/contexts/wikia.jsonld", "@graph": [ "@id": "500f1a1b6e7f1827ba000001", { "@type": "wikia:VideoGame", "@id": "500f1a1b6e7f1827ba000001", "name": "Call of Duty: Black Ops", "@type": "wikia:VideoGame", "publisher": [ "name": "Call of Duty: Black Ops", { "publisher": [ "@id": "501067246e7f184553000001", "501067246e7f184553000001", "name": "Activision", "5010675a6e7f18464d000001" "url": "http://callofduty.wikia.com/wiki/Activision", ] "@type": "schema:Corporation" }, { }, { "@id": "501067246e7f184553000001", "@id": "5010675a6e7f18464d000001", "name": "Activision", "@type": "schema:Corporation", "url": "http://callofduty.wikia.com/wiki/Activision", "name": "Square Enix (Japan)" "@type": "schema:Corporation" } }, { ] "@id": "5010675a6e7f18464d000001", } "@type": "schema:Corporation", "name": "Square Enix (Japan)" } ] }
  • 22. Nesting Flattened Form Nested Form: { { "@context": "/contexts/wikia.jsonld", "@context": "/contexts/wikia.jsonld", "@graph": [ "@id": "500f1a1b6e7f1827ba000001", { "@type": "wikia:VideoGame", "@id": "500f1a1b6e7f1827ba000001", "name": "Call of Duty: Black Ops", "@type": "wikia:VideoGame", "publisher": [ "name": "Call of Duty: Black Ops", { "publisher": [ "@id": "501067246e7f184553000001", "501067246e7f184553000001", "name": "Activision", "5010675a6e7f18464d000001" "url": "http://callofduty.wikia.com/wiki/Activision", ] "@type": "schema:Corporation" }, { }, { "@id": "501067246e7f184553000001", "@id": "5010675a6e7f18464d000001", "name": "Activision", "@type": "schema:Corporation", "url": "http://callofduty.wikia.com/wiki/Activision", "name": "Square Enix (Japan)" "@type": "schema:Corporation" } }, { ] "@id": "5010675a6e7f18464d000001", } "@type": "schema:Corporation", "name": "Square Enix (Japan)" } ] }
  • 23. In-memory linking Flattened Form Linked Form: { "@id": "500f1a1b6e7f1827ba000001", @id 500f1a1b6e7f1827ba000001 "type": "wikia:VideoGame", "schema:name": "Call of Duty: Black Ops", type wikia:VideoGame "wikia:event": [ {"@id": "500f28856e7f187196000001"}, name "Call of Duty: Black Ops" {"@id": "500f44556e7f18f7ef000001"}, event 500f28856e7f187196000001 {"@id": "500f449e6e7f18f94b000001"}, {"@id": "500f44e26e7f18fa75000001"} ] }, { @id 500f28856e7f187196000001 "@id": "500f28856e7f187196000001", type cod:Mission "type": "cod:Mission", "schema:name": "Operation 40", name "Operation 40" "schema:startDate": "1961-04-17", startDate "1961-04-17" "wikia:eventIn": [ {"@id": "500f1a1b6e7f1827ba000001"} event 500f1a1b6e7f1827ba000001 ] }
  • 24. Turtle Mapping { @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . "@context": "/contexts/wikia.jsonld", @prefix schema: <http://schema.org/> . "@id": "500f1a1b6e7f1827ba000001", @prefix wikia: <http://data.wikia.com/terms#> . "@type": "wikia:VideoGame", @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . "contentRating": [ "ESRB: Mature (DS version is Teen)", <500f1a1b6e7f1827ba000001> a wikia:VideoGame; "PEGI: 18+ (DS version is 16+) ", schema:contentRating "ESRB: Mature (DS version is Teen)"@en, "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)" "PEGI: 18+ (DS version is 16+) "@en, ], "USK: 18 CERO: Z OFLC: MA15+ (DS version is M)"@en; "datePublished": "2011-11-09", schema:datePublished: "2011-11-09"^^xsd:dateTime; "name": "Call of Duty: Black Ops", schema:name "Call of Duty: Black Ops"@en; "publisher": [ schema:publisher <501067246e7f184553000001>, {"@id": "501067246e7f184553000001"}, <5010675a6e7f18464d000001> . {"@id": "5010675a6e7f18464d000001"} wikia:event <500f28856e7f187196000001>, ], ...; "wikia:event": [ . {"@id": "500f28856e7f187196000001"}, ... ] }
  • 25. More JSON-LD Features* • @set, @list, • Embedded Compact IRIs, @context Unlabeled Nodes definitions • Language maps • Named Graphs • Property generators * http://json-ld.org/spec/latest/json-ld-syntax
  • 26. History • 2009 – Started as a way to project from the RDFa API • Developers want solutions to work within HTML applications • Desire for JSON-idiomatic way of representing RDF (Linked Data) • Adapt existing JSON APIs to Linked Data
  • 27. History • 2011 – W3C Community Group launched • Broad Participation • Separation of Syntax from API • Proposed to W3C RDF 1.1 Working Group
  • 28. History • 2012 – RDF WG abandons other JSON serialization efforts (RDF/JSON) • JSON-LD accepted as official work item • Community Group drafts final report • RDF WG publishes JSON-LD (Syntax and API) as FPWD
  • 29. MongoDB • JSON-like document store • BSON supports extra datatypes • Certain key patterns are restricted • e.g., “.” not allowed in a key • Query on value = pattern or value includes pattern
  • 31. Wikia Application • Express Wiki content as structured data • Wiki markup doesn’t naturally include semantic cues (Semantic Media Wiki aside). • Add semantic markup to HTML generated from Wikis in RDFa • Aggregate structured content through JSON-LD/MongoDB powered data service
  • 32. Service Architecture • MongoDB persistence • JSON document representation • JSON-LD describedby link header • Ruby/Sinatra web service • Content-negotiated access to data • JSON-LD, HTML, Turtle, ...
  • 33. Document Model { • Use aliases for @id and "id": "500f1a1b6e7f1827ba000001", "type": "wikia:VideoGame", @type keywords "name": "Call of Duty: Black Ops", "publisher": [ • Simplifies use within "501067246e7f184553000001", "5010675a6e7f18464d000001" client-side MVC ], "wikia:event": [ frameworks (e.g. "500f28856e7f187196000001" backbone.js) ] }
  • 34. Document Model { "id": "500f1a1b6e7f1827ba000001", "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", • Individual subject "publisher": [ "501067246e7f184553000001", definition as Mongo "5010675a6e7f18464d000001" document ], "wikia:event": [ "500f28856e7f187196000001" ] }
  • 35. Document Model { "id": "500f1a1b6e7f1827ba000001", • Use expanded subject "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", references "publisher": [ {"id": "501067246e7f184553000001"}, {"id": "5010675a6e7f18464d000001"} ➡This allows simple ], "wikia:event": [ traversal for graphify {"id": "500f28856e7f187196000001"} ] }
  • 36. Document Model { "id": "500f1a1b6e7f1827ba000001", • "type": "wikia:VideoGame", Gather subject "name": "Call of Duty: Black Ops", "publisher": [ references under a {"id": "501067246e7f184553000001"}, hidden key {"id": "5010675a6e7f18464d000001"} ], "wikia:event": [ ➡This allows easy ], {"id": "500f28856e7f187196000001"} querying for objects "_references": [ referencing another "501067246e7f184553000001", "5010675a6e7f18464d000001", object "500f28856e7f187196000001" ] }
  • 37. Document Model GET http://example.com/collection/ 500f1a1b6e7f1827ba000001 HTTP/1.1 200 OK Content-Type: application/json;charset=utf-8 Link: </contexts/wikia.jsonld>; rel="describedby"; type="application/ld+json" • Return context as HTTP { Link Header "id": "500f1a1b6e7f1827ba000001", "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", "publisher": [ {"id": "501067246e7f184553000001"}, {"id": "5010675a6e7f18464d000001"} ], "wikia:event": [ {"id": "500f28856e7f187196000001"} ] }
  • 38. Restful Endpoints GET http://example.com/collection/? withType="schema:Corporation" Accept: application/json HTTP/1.1 200 OK • index – query collection Content-Type: application/json;charset=utf-8 Link: </contexts/wikia.jsonld>; rel="describedby"; type="application/ld+json" • by type – return [ objects having (or { containing) a type "id": "501067246e7f184553000001", "type": "schema:Corporation", "name": "Activision", "url": "http://callofduty.wikia.com/wiki/Activision" }, { "id": "5010675a6e7f18464d000001", "type": "schema:Corporation", "name": "Square Enix (Japan)" } ]
  • 39. Restful Endpoints • GET http://example.com/collection/? index – query collection referencing="500f1a1b6e7f1827ba000001" Accept: application/json • by referencing – HTTP/1.1 200 OK return objects Content-Type: application/json;charset=utf-8 Link: </contexts/wikia.jsonld>; rel="describedby"; referencing another type="application/ld+json" object [{ "id": "500f28856e7f187196000001", • Build out space "cod:game": {"id": "500f1a1b6e7f1827ba000001"}, "schema:name": "Operation 40", around an object "schema:startDate": "1961-04-17T00:00:00", "wikia:eventIn": [{"id": "500f1a1b6e7f1827ba000001"}], "wikia:next": {"id": "500f44556e7f18f7ef000001"}, • Similar to SPARQL "wikia:objective": [ {"id": "501445266e7f1847c6000001"}, describe {"id": "50143e1e6e7f18256d000001"}, ... ], }, ...]
  • 40. Restful Endpoints GET http://example.com/collection/ 500f1a1b6e7f1827ba000001 Accept: application/json HTTP/1.1 200 OK Content-Type: application/json;charset=utf-8 Link: </contexts/wikia.jsonld>; rel="describedby"; • type="application/ld+json" GET – return single { object "id": "500f1a1b6e7f1827ba000001", "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", "publisher": [ {"id": "501067246e7f184553000001"}, {"id": "5010675a6e7f18464d000001"} ] }
  • 41. Restful Endpoints POST http://example.com/collection/ Accept: application/json Content-Type: application/json { • POST – Create new "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops" object } HTTP/1.1 201 Created • Content-Type: application/json;charset=utf-8 Good practice to Link: </contexts/wikia.jsonld>; rel="describedby"; type="application/ld+json" maintain dateCreated Location: http://example.com/collection/ and dateModified 500f1a1b6e7f1827ba000001 equivalents { "id": "500f1a1b6e7f1827ba000001", "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", "dateCreated": "2012-08-23T14:00:00-08:00", "dateModified": "2012-08-23T14:00:00-08:00", }
  • 42. Restful Endpoints PUT http://example.com/collection/ 500f1a1b6e7f1827ba000001 Accept: application/json Content-Type: application/json HTTP/1.1 200 OK Content-Type: application/json;charset=utf-8 • PUT – Update object Link: </contexts/wikia.jsonld>; rel="describedby"; type="application/ld+json" • Good practice to { "id": "500f1a1b6e7f1827ba000001", update dateModified "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", equivalent "publisher": [ {"id": "501067246e7f184553000001"}, {"id": "5010675a6e7f18464d000001"} ], "dateCreated": "2012-08-23T14:00:00-08:00", "dateModified": "2012-08-23T14:15:00-08:00", }
  • 43. Restful Endpoints DELETE http://example.com/collection/ • DELETE – Destroy 500f1a1b6e7f1827ba000001 object HTTP/1.1 204 No Content
  • 44. Restful Endpoints GET http://example.com/collection/ 500f1a1b6e7f1827ba000001/publisher/ Accept: application/json HTTP/1.1 200 OK • path – relational query Content-Type: application/json;charset=utf-8 Link: </contexts/wikia.jsonld>; rel="describedby"; type="application/ld+json" • Return objects having [ a property { "id": "501067246e7f184553000001", relationship with "type": "schema:Corporation", another object "name": "Activision", "url": "http://callofduty.wikia.com/wiki/ Activision" }, { "id": "5010675a6e7f18464d000001", "type": "schema:Corporation", "name": "Square Enix (Japan)" } ]
  • 45. Restful Endpoints GET http://example.com/collection/ 500f1a1b6e7f1827ba000001 Accept: application/ld+json HTTP/1.1 200 OK Content-Type: application/ld+json;charset=utf-8 • GET – as explicit JSON- { "@context": "/contexts/wikia.jsonld", LD "id": "500f1a1b6e7f1827ba000001", "type": "wikia:VideoGame", "name": "Call of Duty: Black Ops", "publisher": [ {"id": "501067246e7f184553000001"}, {"id": "5010675a6e7f18464d000001"} ] }
  • 46. Working with data • Application Structure • Ruby/Sinatra REST service • JavaScript/Backbone.js client { • Alias JSON-LD "@context": { "id": "@id", keywords for "type": "@type" convenience } }
  • 47. MVC Client • Natural access from client-side MVC (e.g., backbone.js) Collection // Object collection, handles objects constructed from OWL classes and properties. // Initial fetch is only for VideoGame types, as referenced objects are // fetched, they are added to the collection. Wikia.ObjectCollection = Backbone.Collection.extend({ initialize: function() { this.model = Wikia.ObjectModel; }, url: function() { return "/api/#{@vers}/#{@name}"; }, comparator: function(model) { return model.get('schema:name') } ... }
  • 48. MVC Client • Natural access from client-side MVC (e.g., backbone.js) Model // OWL model class and sub-classes for dealing with owl:Class, // owl:DatatypeProperty, owl:ObjectProperty and owl:Datatype Wikia.ObjectModel Backbone.Model.extend({ referencedObjects: function() { return this.resolve(_.flatten(_.toArray(this.attributes))); }, getModel: function(key, options) { return this._resolve this.get(key)) }, setModel: function(key, value) {...}, _resolve: function(value) {...}, ... }
  • 49. Summary • JSON-LD is a light-weight layer for representing linked data in JSON • The MongoDB document model is a natural fit for JSON-LD • Not optimized for SPARQL; consider alternatives • Single Page Applications benefit from linked data principles • RDF with OWL can be powerful when used appropriately in the client
  • 50. Resources • JSON-LD Syntax • http://w3.org/TR/json-ld-syntax • JSON-LD API • http://w3.org/TR/json-ld-api • Git Repo • https://github.com/json-ld/json-ld.org • Information/Playground • http://json-ld.org/ • IRC • #json-ld on Freenode
  • 51. More Information json-ld.org JavaScript Ruby rdf-comments@w3.org Python PHP Java Gregg Kellogg gregg@greggkellogg.net http://greggkellogg.net/ @gkellogg

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. JSON-LD brings a standard representation for expressing entity-value relationships using a few standard keywords and a consistent organizational structure for JSON Objects.\nObjects represent entities, with keys acting as properties.\n Properties always expand to full IRIs.\nArrays express a set of values associated with a property, unordered by default.\n Order expressed in @context or as an expanded value representation.\nValues are Object, string or native, with standard XSD representations for native types.\n Expanded form allows for more datatype and language variations.\n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. It&amp;#x2019;s important to note that JSON-LD is a product of the W3C RDF Working group, and is as much &amp;#x201C;RDF&amp;#x201D; as any other serialization format.\nIn this case, we show a transformation from the JSON-LD format of a resource description to Turtle, an RDF format specifically intended to be humanly readable.\n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. Subject reference identifies an object with @id in the same document, or references an external document (Linked Data).\n
  54. \n
  55. \n
  56. What I&apos;ve outlined is not really optimized for SPARQL. For performance, you&apos;re much better at storing triples as documents, then full-on subject definitions.\n\nThis application is more tuned for returning collections of subject definitions based on a fairly narrow query bounds (resources relevant to a particular point in game play) then general querying. In fact, I&apos;ve considered that an evolution of the application I&apos;m working on may well go to a generic SPARQL store, with good JSON-LD support, such as Stardog.\n\n
  57. \n
  58. \n