I'm attempting to compact at JSON-LD document, see below (we're using URNs but the same issue occurs with URLs). I want "org:example:property:schema;2"to be compacted to schema in both of the usages below, and the nested objects of the schema property to also be compacted reasonably. Sadly, this seems so far impossible.
[
{
"@id": "org:example:ExampleThing",
"org:example:property:contents;2": [
{
"@type": "org:example:class:Property;2",
"org:example:property:schema;2": {
"@id": "org:example:instance:Schema:integer;2"
}
}
]
},
{
"@id": "org:example:ExampleThing2",
"org:example:property:contents;2": [
{
"@type": "org:example:class:Property;2",
"org:example:property:schema;2": {
"@type": "org:example:class:Enum;2",
"org:example:property:valueSchema;2": {
"@id": "org:example:instance:Schema:string;2"
}
}
}
]
}
]
What I would like to get out is the following:
[
{
"@id": "org:example:ExampleThing",
"contents": {
"@type": "Property",
"schema": {
"@id": "integer"
}
}
},
{
"@id": "org:example:ExampleThing2",
"contents": {
"@type": "Property",
"schema": {
"@type": "Enum",
"valueSchema": "string"
}
}
}
]
The closest I've gotten is the following context. In it, however, org:example:instance:Schema:integer;2 is not compacted as required. Adding "@type": "@vocab" to the schema definition resolves this for ExampleThing, but then the schema term does not match the usage of the property in ExampleThing2, so it is not compacted there instead.
{
"Property": { "@id": "org:example:class:Property;2" },
"Enum": { "@id": "org:example:class:Enum;2" },
"contents": { "@id": "org:example:property:contents;2" },
"schema": { "@id": "org:example:property:schema;2" },
"valueSchema": {
"@id": "org:example:property:valueSchema;2",
"@type": "@vocab"
},
"integer": { "@id": "org:example:instance:Schema:integer;2" },
"string": { "@id": "org:example:instance:Schema:string;2" }
}