I have the following json merged with context below,
Currently I am facing 2 problems
1 the duplicate keys or properties that are present in the JSON at different levels how to deal with those so I can have the correct triples connected to each other?
2 @vocab is ignored where I have use @id like on rowid and it adds a default prefix in json-ld playground
{
"@context": {
"@vocab": "http://xyz.qte.com/01#",
"xxx": "http://xyz.qte.com/01#",
"@base": "http://xyz.qte.com/01#",
"rowid": "@id",
"values": "@nest",
"relation": "@nest",
"blobs": "@nest",
"displaytypename": {
"@id": "http://www.w3.org/2000/01/rdf-schema#label",
"@type": "@id"
},
"type": "@type",
"blobid": {
"@id": "cccmi:blobid",
"@type": "@id"
}
},
"@id": "xxx:abs",
"type": "abs",
"objectversion": 15,
"displaytypename": "ABS",
"displaytypenamelang": "en",
"objectid": "123456",
"typeversion": "r34",
"values": [{
"value": 278494
}],
"rows": [{
"rowid": "123",
"displaytypename": "asdf",
"displaytypenamelang": "en",
"type": "affected_objects",
"values": [{
"value": "1234"
}]
},
{
"rowid": "345",
"displaytypename": "bla",
"displaytypenamelang": "en",
"type": "affected_objects2",
"values": [{
"value": "5678"
}],
"relation": {
"rows": [{
"rowid": "678",
"displaytypename": "baba",
"type": "affected_objects3",
"values": [{
"value": "General"
}],
"relation": {
"rows": [{
"rowid": "546",
"displaytypename": "bla",
"displaytypenamelang": "en",
"type": "affected_objects4",
"values": [{
"value": "2002-09-04"
}]
},
{
"rowid": "874",
"displaytypename": "blah",
"displaytypenamelang": "en",
"type": "affected_objects5",
"values": [{
"value": "TMBLA"
}]
},
{
"rowid": "973",
"displaytypename": "blah",
"displaytypenamelang": "en",
"type": "affected_objects6",
"values": [{
"value": "456"
}]
}
]
}
}]
}
},
{
"rowid": "987",
"displaytypename": "bllah",
"displaytypenamelang": "en",
"type": "co_issue",
"values": [{
"value": 3
}],
"relation": {
"rows": [{
"rowid": "163",
"displaytypename": "blaj",
"displaytypenamelang": "en",
"type": "affected_objects7",
"values": [{
"value": "Exists"
}],
"blobs": [{
"mime_type": "abc",
"blobid": "2344"
}]
}
]
}
}
]
}
By "duplicate keys", I presume you mean the same term used as a property key at different levels of the JSON document. For this, JSON-LD has the notion of a Scoped Context, whereby you can have a context come into play inside of the value of some property, or where a type is in effect. In this way, for example, you could define "value" to map to one IRI at the top level, and within the term definition of "value" (or some other intervening property), define a new context which redefines the mapping for "value"
Regarding @vocab
and @id
, @id
is considered a document-relative term, and string values are expanded from the document base, or @base
, if defined in the active context (see section 4.1.3 Base IRI). @vocab
is used for expanding vocabulary-relative term such as @type
and object property keys, which aren't otherwise defined as terms (see section 4.1.2 Default Vocabulary.
I just have another question now with the sample above I get the desired result but is it somehow possible to change the predicate rows to something that relative to each block like hasaffectedobject or hasaffectedobject2 for each rowid instead of having rows for all eg <xyz.qte.com/01#abs> <xyz.qte.com/01#rows> <xyz.qte.com/123> . <xyz.qte.com/01#abs> <xyz.qte.com/01#rows> <xyz.qte.com/345> . <xyz.qte.com/01#abs> <xyz.qte.com/01#rows> <xyz.qte.com/987> . should have different predicates that is dependent on the type of each row
You can hard-code the propertyUrl for each column, or build it using the rules described for URI Template Properties (w3.org/TR/tabular-metadata/#uri-template-properties).