Re: Merging JSON-LD graphs

I think you mean RDF graphs. We shouldn’t repeat the mistakes that were
made with RDF/XML and conflate the model and the serialization(s).

If you read both graphs into an RDF dataset using library such as Jena or
RDF4J or Python’s RDFLib, you can then re-serialize them into a single file
(JSON-LD or other).
On Fri, 13 Jul 2018 at 13.13, Angelo Veltens <angelo.veltens@online.de>
wrote:

> 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:48:35 UTC