Re: Tagging JSON files with their purpose

Hi Andy,

JSON-LD is a way to represent Linked Data. Everything should be identified
by IRIs (a kind of unique web addresses).

In your example, we want to represent a list of results. Every 'result' in
the list may have specific information (the properties we are defining for
those entities or classes). So we should indicate the type of JSON object
(using @type or we can use an alias) you are describing. You are right, we
should declare something like:
{
   @type="meeting_result",
   ....
}

We will use existing types (e.g., schema:Person) and we are defining others
we need (e.g. Athlete, Result, Performance, etc.).

I've created a complex real example [1] where you can see how a list of
results may be described:
{
...
            "results": [
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_1
",
                "@type": "Result",
                "name": "1st Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_121Schippers
",
                "trackLane": 7,
                "rank": 1,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_121Schippers
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/121Schippers.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:10.900"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_2
",
                "@type": "Result",
                "name": "2nd Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_124LalovaCollio
",
                "trackLane": 6,
                "rank": 2,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_124LalovaCollio
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/124LalovaCollio.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:11.200"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_3
",
                "@type": "Result",
                "name": "3rd Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_129Kambundji
",
                "trackLane": 4,
                "rank": 3,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_129Kambundji
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/129Kambundji.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:11.250"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_4
",
                "@type": "Result",
                "name": "4th Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_122Philip
",
                "trackLane": 9,
                "rank": 4,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_122Philip
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/122Philip.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:11.270"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_5
",
                "@type": "Result",
                "name": "5th Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_126Pohrebnyak
",
                "trackLane": 2,
                "rank": 5,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_126Pohrebnyak
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/126Pohrebnyak.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:11.280"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_6
",
                "@type": "Result",
                "name": "6th Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_125Pinto
",
                "trackLane": 8,
                "rank": 6,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_125Pinto
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/125Pinto.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:11.330"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_7
",
                "@type": "Result",
                "name": "7th Position - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_130Gnafoua
",
                "trackLane": 3,
                "rank": 7,
                "performance": {
                  "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_130Gnafoua
",
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/130Gnafoua.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:11.360"
                }
              },
              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_8
",
                "@type": "Result",
                "name": "DNF - 100m Women - Final",
                "competitionEntry": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_128Henry
",
                "trackLane": 5,
                "bibIdentifier": "128",
                "competitionFeature": "DNF"
              }
            ]
...}

I think it's self-descriptive. The only weird thing you might see is
'competitionEntry'. Each entry of the competition is already declared on
top of the document. For instance, the first ranked athlete in the example
could be represented nested as follows:

              {
                "@id": "
http://w3c.github.io/opentrack-cg/examples/competition/Euro2016.jsonld#100W_Final_1
",
                "@type": "Result",
                "name": "1st Position - 100m Women - Final",
                "competitionEntry":
       {
          "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/121Schippers.jsonld",
          "@type": "CompetitionEntry",
          "bibIdentifier": "121"
        },
                "trackLane": 7,
                "rank": 1,
                "performance": {
                  "@type": "TimePerformance",
                  "competitor": "
http://w3c.github.io/opentrack-cg/examples/athlete/121Schippers.jsonld",
                  "windAssistance": "-0.2 m/s",
                  "time": "00:00:10.900"
                }
              },

Of course, if you don't include a type, the JSON will be correct, but we
loss semantics. It is recommended to add one of more types [2] to those
JSON-LD objects.

Let me know if this clarify your doubts.

Cheers,

Martin

[1]
https://raw.githubusercontent.com/w3c/opentrack-cg/master/examples/competition/Euro2016.jsonld
[2]
https://json-ld.org/spec/latest/json-ld-api-best-practices/#typed-objects




On Tue, Jun 13, 2017 at 10:24 AM Andy Robinson <andy@reportlab.com> wrote:

> If we're producing JSON formats (not full json-ld)  for a specific
> purpose, which we still want to formalise, should we have something at
> the top level to indicate the type or the schema?
>
> For example, if the purpose is "results of some races" (like this...
>
>     https://entries.opentrack.run/2017/not/json_results/
>
> ...should we have something at the top like this?
>
> {
>
>     "type": "meeting_results"
>
> or perhaps
>
>     "schema": "http://opentrack.run/schemas/meeting_results.json"
> }
>
> I see that the JSON-LD samples use "@type", but wonder if this is
> appropriate for a message format, rather than an entity with a unique
> URL.
>
>
>
>
> --
> Andy Robinson
>
>

Received on Tuesday, 13 June 2017 11:41:50 UTC