W3C home > Mailing lists > Public > public-linked-json@w3.org > August 2016

Re: JSON-LD & nested structure

From: Aymeric Brisse <aymeric.brisse@gmail.com>
Date: Fri, 26 Aug 2016 10:42:41 +0200
Message-ID: <CANURzhh3GPO-Kmyd50_DbCoe_pmhVm14MzmY6n4WiunMJ1BxqQ@mail.gmail.com>
To: Markus Lanthaler <markus.lanthaler@gmx.net>
Cc: JSON-LD CG <public-linked-json@w3.org>, Hydra <public-hydra@w3.org>, Gregg Kellogg <gregg@greggkellogg.net>
Hello Markus,

On Thu, Aug 25, 2016 at 10:01 PM, Markus Lanthaler <markus.lanthaler@gmx.net
> wrote:

> On Thursday, August 25, 2016 12:31 PM, Aymeric Brisse wrote:
> > On Thu, Aug 25, 2016 at 1:55 AM, Gregg Kellogg wrote:
> >> The Hydra CG is working on issues such as pagination [1], which is
> >> more than just a JSON-LD issue. As with other things in Hydra, this
> >> remains a work in progress.
> >
> > 1/ It seems to focus only on paginating top-items, which is only a
> > small part of the problem like I said in my previous mail.
>
> Could you please explain what you mean by top-items? JSON-LD serializes
> graphs, so there's no hierarchy.. are you talking of the outermost entity
> in the JSON serialization?
>

I am using JSON-LD Framing to apply a specific tree layout, hence the
top-items I am talking about. Like /person/alice/friends in which alice is
the root node, but the friends are the top-items in my reponse since the
relation is expressed in the route.

My question is if the developer wants in the same response the first 10
friends and the first 2 countries visited by each of these persons, how can
I express the number of countries visited by each friends with Hydra?
Basically I am trying to do is returning a JSON-LD valid structure that
contains all this information (that's the whole point of graphQL / JSON
graph). It's like merging several JSON-LD graphes into one.

As a developer, I would like to deal with something like :

{
  "@context": {
    "kb": "http://www.example.com/resource/",
    "pmcore": "http://www.example.com/ontology/pmcore/1.0#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
  },
  "@graph": [
    {
      "@id": "kb:JohnDoe",
      "@types": [
        "pmcore:person"
      ],
      "pmcore:created_at": "2016-03-16T14:08:26.653Z",
      "rdfs:label": "John Doe"
      },
      "pmcore:hasVisited": {
        "@graph": [
          {
            "@id": "kb:US",
            "@types": [
              "pmcore:country"
            ],
            "pmcore:thumbnail": "
http://freebase.com/6f42b4cf421496588c9c25ecda7192485ffbb678",
            "rdfs:label": "United States"
          },
          {
            "@id": "kb:Germany",
            "@types": [
              "pmcore:country"
            ],
            "pmcore:thumbnail": "
http://freebase.com/6f42b4cf421496588c9c25ecda7192485ffbb678",
            "rdfs:label": "Germany"
          },
        ],
        "@metadata": {
          "total_count": 5
        }
      }
    },
    {
      "@id": "kb:Smith",
      "@types": [
        "pmcore:person"
      ],
      "pmcore:created_at": "2016-03-16T14:08:26.653Z",
      "rdfs:label": "Smith"
      },
      "pmcore:hasVisited": {
        "@graph": [
          {
            "@id": "kb:US",
            "@types": [
              "pmcore:country"
            ],
            "pmcore:thumbnail": "http://url.com/x",
            "rdfs:label": "United States"
          },
          {
            "@id": "kb:France",
            "@types": [
              "pmcore:country"
            ],
            "pmcore:thumbnail": "http://url.com/x",
            "rdfs:label": "France"
          },
        ],
        "@metadata": {
          "total_count": 3
        }
      }
    }
  ],
  "@metadata": {
    "total_count": 2
  }
}


>
>
> > 2/ Moreover the idea on the whole page is to basically add an extra
> > top-level "Collection", which is mixing Form and Substance.
>
> Yeah, that's a tricky issue. We tried to devouple that by extracting the
> collection instead of sticking it between the two entities, see
>
>   https://www.w3.org/community/hydra/wiki/Collection_Design#Pr
> oposed_Collection_Design


Yes it makes total sense in a formal RESTful way.


>
>
>
> [...]
>
> > Since JSON-LD is mandatory for me to express semantically the
> > concepts, I guess I would add my "@metadata" field with the merging
> > solution until then. Please let me know if I can help in any way with
> > some specifications/inputs as a developer "in the field".
>
> You should join the Hydra W3C Community Group and provide input to the
> specification. Details can be found here:
>
>    http://www.hydra-cg.com/#community
>
> (we are in a summer break at the moment so don't expect too much activity
> on the mailing list)
>

Done! I need to read a little more about the Hydra project that seems
indeed to try to solve interesting problematics. I just have to check that
it is not correlated too much to the formal RESTful approach.


>
>
> Cheers,
> Markus
>

Cheers!


>
>
> >> [1] https://www.w3.org/community/hydra/wiki/Pagination
>
> --
> Markus Lanthaler
> @markuslanthaler
>
>
>
>
Received on Friday, 26 August 2016 08:43:32 UTC

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