Using a key value as the @id

We want to generate a JSON-LD object from a JSON one by adding the @context.

The destination object is, for example

[
   {
     "CPV:name": [
       {
         "@value": "Fred"
       }
     ],
     "@id": "https://w3id.org/person/AA123456CC"
   }
]

While the source object is

{

   "name": "Fred",
   "personID": "AA123456CC"
}

We would like to have a @context that converts source to destination.

A working example could be


{
   "@context":{
     "@vocab":"CPV:",
     "personID": "@id",
     "@base":"https://w3id.org/person/"
   },

   "name": "Fred",
   "personID": "AA123456CC"
}

However, this seems an overload of the meaning of "@base", which 
shouldn't be used just for one @id, but as the base URI of a number of 
@id-s.

Is there another more standard way?

Thank you

Here's the playground version:

https://tinyurl.com/27rxs2yj

Received on Friday, 27 September 2024 13:36:58 UTC