Merging JSON-LD graphs

Hi,

I am looking for best practices regarding merging facts into a unified 
JSON-LD graph.

My approach for this is the following. I would like to get some feedback 
or ideas for doing it better.

For example I get the following data from a server:

{
   "@context": {
     "@vocab": "http://schema.org/"
   },
   "@type": "Person",
   "@id": "/person/42",
   "name": "Jane Doe"
}

I flatten it without a context got get this:

{
   "@graph": [
     {
       "@id": "/person/42",
       "@type": "http://schema.org/Person",
       "http://schema.org/name": "Jane Doe"
     }
   ]
}

I do the same with further data I load, e.g. a second person:

{
   "@graph": [
     {
       "@id": "/person/43",
       "@type": "http://schema.org/Person",
       "http://schema.org/name": "John Doe"
     }
   ]
}

Now I can merge the graphs by appending the arrays:

{
   "@graph": [
     {
       "@id": "/person/42",
       "@type": "http://schema.org/Person",
       "http://schema.org/name": "Jane Doe"
     },
     {
       "@id": "/person/43",
       "@type": "http://schema.org/Person",
       "http://schema.org/name": "John Doe"
     }
   ]
}


What do you think about this procedure? Is there an easier way to 
achieve it? May it have any issues for more complex graphs?

Thanks in advance and best regards,
Angelo

Received on Friday, 13 July 2018 11:12:17 UTC