Item:OSW911488771ea449a6a34051f8213d7f2f: Difference between revisions

m
Protected "JSON-LD Tutorial": Protected as read-only import via Page Exchange extension ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]
(Install package: OSW Docs - Core)
 
m (Protected "JSON-LD Tutorial": Protected as read-only import via Page Exchange extension ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading])
 
(3 intermediate revisions by the same user not shown)
Line 63: Line 63:
JSON-LD allows the import of context(s) from other JSON documents
JSON-LD allows the import of context(s) from other JSON documents
* Prefixes and mappings can be moved to a remote context  
* Prefixes and mappings can be moved to a remote context  
<syntaxhighlight lang="json-ld">
<nowiki>http://myschema.org/allmyquantitites.jsonld</nowiki><syntaxhighlight lang="json-ld">
{
    "@context": {
        "qudt": "http://qudt.org/vocab/quantitykind/",
        "cap": "qudt:Capacitance",       
    }
}
</syntaxhighlight><syntaxhighlight lang="json-ld">
{
{
     "@context": [
     "@context": [
Line 74: Line 81:
     "current": 10.0  
     "current": 10.0  
}
}
</syntaxhighlight><div></div>
</syntaxhighlight>
 
== JSON-LD: Mapping (4) - Full example ==
Actually this example was oversimplified. A full semantic representation would be
 
<nowiki>http://myschema.org/allmyquantitites.jsonld</nowiki><syntaxhighlight lang="json-ld">
{
    "@context": {
        "qudt": "http://qudt.org/schema/qudt/",
        "qunit": "http://qudt.org/vocab/unit/",
        "qkind": "http://qudt.org/vocab/quantkind/",
        "unit": {
          "@id": "qudt:hasUnit",
          "@type": "@id"
        },
        "value": "qudt:value" 
    }
}
</syntaxhighlight><syntaxhighlight lang="json-ld">
{
  "@context": "http://myschema.org/allmyquantitites.jsonld",
  "value": 4.0,
  "unit": "qunit:CentiM"
}
</syntaxhighlight>which would translate to <code><pint.Quantity(4.0, 'centimeter')></code> in python, see [https://github.com/hampusnasstrom/ontopint]<div>
== JSON-LD: Advanced concepts==
There are many more feature of JSON-LD - see specification [https://www.w3.org/TR/json-ld/]
 
* Property types, object properties
* Reverse Properties
* Arrays and containers
* Multi-language strings
* Framing
* ...
 
In general JSON-LD is not only about annotation but also transformation and normalization


== JSON-LD: Mapping (3) - Nested context==
== JSON-LD: Scopes ==
A property / the related subobject can have it's own context. The global context is inherited. [https://json-ld.org/playground/#startTab=tab-expanded&json-ld=%7B%22%40context%22%3A%7B%22test%22%3A%22http%3A%2F%2Ftest.org%2F%22%2C%22id%22%3A%22test%3AHasId%22%2C%22name%22%3A%22test%3AHasName%22%2C%22subobject%22%3A%7B%22%40id%22%3A%22test%3AHasSubobject%22%2C%22%40context%22%3A%7B%22id%22%3A%22test%3AHasSubId%22%7D%7D%7D%2C%22name%22%3A%22Test%201%22%2C%22id%22%3A%221%22%2C%22subobject%22%3A%7B%22name%22%3A%22Test%201.1%22%2C%22id%22%3A%221.1%22%7D%7D&context=%7B%7D Playground]
A property / the related subobject can have it's own context. The global context is inherited. [https://json-ld.org/playground/#startTab=tab-expanded&json-ld=%7B%22%40context%22%3A%7B%22test%22%3A%22http%3A%2F%2Ftest.org%2F%22%2C%22id%22%3A%22test%3AHasId%22%2C%22name%22%3A%22test%3AHasName%22%2C%22subobject%22%3A%7B%22%40id%22%3A%22test%3AHasSubobject%22%2C%22%40context%22%3A%7B%22id%22%3A%22test%3AHasSubId%22%7D%7D%7D%2C%22name%22%3A%22Test%201%22%2C%22id%22%3A%221%22%2C%22subobject%22%3A%7B%22name%22%3A%22Test%201.1%22%2C%22id%22%3A%221.1%22%7D%7D&context=%7B%7D Playground]
<syntaxhighlight lang="json-ld">
<syntaxhighlight lang="json-ld">
Line 99: Line 141:
}
}
</syntaxhighlight><div></div>
</syntaxhighlight><div></div>
</div>


==JSON-LD: Flatten a hierarchy==
==JSON-LD: Flatten a hierarchy==
Line 349: Line 392:


==JSON Documents: Next==
==JSON Documents: Next==
*[[Item:OSWee501c0fa6a9407d99c058b5ff9d55b4]] [{{fullurl:Item:OSWee501c0fa6a9407d99c058b5ff9d55b4|reveal=true}} Slideshow]
*[[Item:OSWee501c0fa6a9407d99c058b5ff9d55b4]] [{{fullurl:Item:OSWee501c0fa6a9407d99c058b5ff9d55b4
|reveal=true
}} Slideshow]
jsondata
Line 1: Line 1:
{
{
    "required_predecessor": [
"required_predecessor": [
        "Item:OSWf1df064239044b8fa3c968339fb93344"
"Item:OSWf1df064239044b8fa3c968339fb93344"
    ],
],
    "optional_predecessor": [
"optional_predecessor": [
        "Item:OSWf4a9514baed04859a4c6c374a7312f10"
"Item:OSWf4a9514baed04859a4c6c374a7312f10"
    ],
],
    "type": [
"type": [
        "Category:OSW494f660e6a714a1a9681c517bbb975da"
"Category:OSW494f660e6a714a1a9681c517bbb975da"
    ],
],
    "uuid": "91148877-1ea4-49a6-a340-51f8213d7f2f",
"uuid": "91148877-1ea4-49a6-a340-51f8213d7f2f",
    "name": "JsonLdTutorial",
"name": "JsonLdTutorial",
    "label": [
"label": [
        {
{
            "text": "JSON-LD Tutorial",
"text": "JSON-LD Tutorial",
            "lang": "en"
"lang": "en"
        }
}
    ],
],
    "image": "File:OSWcdf1d2e2f5d143aeb13096013632c8cb.png",
"image": "File:OSWcdf1d2e2f5d143aeb13096013632c8cb.png",
    "recommended_successor": [
"recommended_successor": [
        "Item:OSWee501c0fa6a9407d99c058b5ff9d55b4"
"Item:OSWee501c0fa6a9407d99c058b5ff9d55b4"
    ]
]
}
}