W3C home > Mailing lists > Public > public-linked-json@w3.org > May 2017

could this json-ld be any simpler than this? (tips for a json-ld noob?)

From: Darren Cruse <darren.cruse@gmail.com>
Date: Mon, 8 May 2017 08:15:53 -0500
Message-ID: <CAOtLU22L++O2axnZAn=6N0huE2Y2JvoNEw4TGeS8dLosgmt5Lw@mail.gmail.com>
To: public-linked-json@w3.org
Was seeing if I followed JSON-LD well enough to convert a real simple (but
real example from my work) JSON over to JSON-LD.

My goal is literally to keep it as simple as it possibly can be, because if
I move forward I will have to sell teammates on the idea who have no
semantic web/linked data background at all who will likely be very
skeptical of the cost/benefit unless it is.

So atm I'm trying to avoid anything but the minimum needed to wind up with
triples I can load into Virtuoso and SPARQL query from there.

My JSON is like so:

{
"crop": {
"Corn": {
"en": "Corn",
"fr": "Blé",
"pt": "Milho"
},
"Soybean": {
"en": "Soybean",
"fr": "Soja",
"pt": "Soja"
}
}
}

And with the help of the playground I came up with the following for my
JSON-LD:

{
    "@context": {
        "@base": "
https://velocity.ag/field-reference-data/field-reference-data.jsonld",
        "id": "@id",
        "type": "@type",
        "groups": "https://velocity.ag/field-reference-data/groups",
        "name": "https://schema.org/name",
        "refcodes": "https://velocity.ag/field-reference-data/refcodes",
        "code": "http://schema.org/code",
        "label": "https://velocity.ag/field-reference-data/label",
        "en": {
            "@id": "https://velocity.ag/field-reference-data/lang/en",
            "@language": "en"
        },
        "fr": {
            "@id": "https://velocity.ag/field-reference-data/lang/fr",
            "@language": "fr"
        },
        "pt": {
            "@id": "https://velocity.ag/field-reference-data/lang/pt",
            "@language": "pt"
        }
    },
    "id": "all",
    "groups": [{
        "id": "crop",
        "name": "crop",
        "refcodes": [{
                "id": "crop/corn",
                "code": "Corn",
                "label": {
                    "id": "crop/corn/label",
                    "en": "Corn",
                    "fr": "Blé",
                    "pt": "Milho"
                }
            },
            {
                "id": "crop/soybean",
                "code": "Soybean",
                "label": {
                    "id": "crop/soybean/label",
                    "en": "Soybean",
                    "fr": "Soja",
                    "pt": "Soja"
                }
            }
        ]
    }]
}

Does this look reasonable? (this is my first JSON-LD ever would love advice
if I've got some things wrong)

And though I'm not terribly unhappy with the above (esp. if I can break the
context part out into a separate standalone file and I see that's possible
correct)...

Is this as simple as it can be?  Could it have been even simpler e.g. in
any way closer to the original JSON?

Thanks appreciate any tips,

Darren
Received on Tuesday, 9 May 2017 11:49:05 UTC

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