W3C home > Mailing lists > Public > public-linked-json@w3.org > July 2018

Re: Merging JSON-LD graphs

From: Martynas Jusevičius <martynas@atomgraph.com>
Date: Fri, 13 Jul 2018 13:47:03 +0200
Message-ID: <CAE35Vmx3_qP0kMaxdzd8zPzP6UyDZ7So=7Y9JHu+wEfwwHCMTQ@mail.gmail.com>
To: Angelo Veltens <angelo.veltens@online.de>
Cc: JSON-LD CG <public-linked-json@w3.org>
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:52 UTC