Item:OSW911488771ea449a6a34051f8213d7f2f: Difference between revisions

From OpenSemanticWorld
update from wiki-dev
(Update package: OSW Docs - Core)
(update from wiki-dev)
Tag: 2017 source edit
 
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==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.