-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Description
I think it would be interesting to add type coercion also to node objects in JSON-LD. Consider a document like
{
"@context": {
"@version": 1.1,
"ex": "http://example.org/",
"things": {"@id":"ex:thing"}
},
"things": [
{"@type": "ex:typeofthing","ex:attribute":"value1"},
{"@type": "ex:typeofthing","ex:attribute":"value2"},
{"@type": "ex:typeofthing","ex:attribute":"value3"}
]
}
it would be nice it I could specify in the context what the "@type" of each node referred to by the predicate "ex:thing" is in order to reduce repetitiveness. Similar how I can do it for terms pointing to literals.
{
"@context": {
"@version": 1.1,
"ex": "http://example.org/",
"things": {"@id":"ex:thing", "@type": "ex:typeofthing"}
},
"things": [
{"ex:attribute":"value1"},
{"ex:attribute":"value2"},
{"ex:attribute":"value3"}
]
}
Right now, @type
seems to just be ignored when the object in the triple is not a literal -- so perhaps it is straight forward to add?
{
"@context": {
"@version": 1.1,
"ex": "http://example.org/",
"ex:term": {"@type":"ex:literaltype"}
},
"ex:term": "literalvalue"
}
expands to
[
{
"http://example.org/term": [
{
"@type": "http://example.org/literaltype",
"@value": "literalvalue"
}
]
}
]
while
{
"@context": {
"@version": 1.1,
"ex": "http://example.org/",
"ex:term": {"@type":"ex:nodetype"}
},
"ex:term": {"@id":"ex:anode"}
}
expands to:
[
{
"http://example.org/term": [
{
"@id": "http://example.org/anode"
}
]
}
]