I have the following JSON document (based on GitHub API output):
{
"@id": "https://github.com/octadocs/octadocs",
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
}
}
Using JSON-LD, I'd like to retrieve the following triple from this:
<https://github.com/octadocs/octadocs>
<https://octadocs.io/github/license>
<https://spdx.org/licenses/MIT> .
- I can interpret
licenseashttps://octadocs.io/github/licensewith@vocab(I would like to use it globally actually, for all properties); - I can specify
@typeforspdx_idto make its value an IRI; - and I finally can define a
@contextwith a@basefor it, to convertMITstring into an spdx.org reference.
Context:
{
"@base": "https://octadocs.io/github/",
"@vocab": "https://octadocs.io/github/",
"spdx_id": {
"@type": "@id",
"@context": {
"@base": "https://spdx.org/licenses/"
}
}
}
See a demonstration in JSON-LD playground.
But, this creates a slightly different structure than the desired one:
<https://github.com/octadocs/octadocs> <https://octadocs.io/github/license> _:b0 .
_:b0 <https://octadocs.io/github/spdx_id> <https://spdx.org/licenses/MIT> .
I'd like to avoid the blank node.
This can be achieved by JSON-LD keyword aliasing:
{
...,
"spdx_id": "@id"
}
but how to simultaneously
- alias the property,
- and define things like
@typeand@contextfor it?