EOL / tramea

A lightweight server for denormalized EOL data
Other
2 stars 1 forks source link

EOL JSON-LD not valid #352

Open jhammock opened 8 years ago

jhammock commented 8 years ago

Cloned from https://github.com/EOL/eol/issues/139, courtesy @rdmpage:

The JSON-LD returned by trait bank fails when parsed by the JSON-LD playground, see http://tinyurl.com/hfoos6p

Here's an example http://eol.org/api/traits/10692652. JSON-LD playground complains about "@id": 10692652, an @id needs to be a string (ideally a URI). I would have thought that "http://eol.org/pages10692652" was the obvious value. Fixing that leads to a second problem,

"vernacularNames": [
      {
        "@language": "en",
        "@value": "Rio Orinoco Spinetail",
        "gbif:isPreferredName": true
      }
    ]

causes the message Invalid JSON-LD syntax; an element containing "@value" may only have an "@index" property and at most one other property which can be "@type" or "@language".

Deleting "gbif:isPreferredName": true fixes that. Once these bugs are fixed, the JSON-LD can be parsed OK.

{
  "@context": {
    "@vocab": "http://schema.org/",
    "dwc:taxonID": {
      "@type": "@id"
    },
    "dwc:resourceID": {
      "@type": "@id"
    },
    "dwc:relatedResourceID": {
      "@type": "@id"
    },
    "dwc:relationshipOfResource": {
      "@type": "@id"
    },
    "dwc:vernacularName": {
      "@container": "@language"
    },
    "eol:associationType": {
      "@type": "@id"
    },
    "rdfs:label": {
      "@container": "@language"
    },
    "dc": "http://purl.org/dc/terms/",
    "dwc": "http://rs.tdwg.org/dwc/terms/",
    "eolterms": "http://eol.org/schema/terms/",
    "eol": "http://eol.org/schema/",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "gbif": "http://rs.gbif.org/terms/1.0/",
    "foaf": "http://xmlns.com/foaf/0.1/"
  },
  "@type": "DataFeedItem",
  "dateModified": "2016-09-22",
  "item": {
    "@id": 10692652,
    "@type": "dwc:Taxon",
    "scientificName": "Synallaxis beverlyae",
    "dwc:taxonRank": "species",
    "dwc:parentNameUsageID": "http://eol.org/pages/15003",
    "potentialAction": {
      "@type": "EntryPoint",
      "target": {
        "@type": "Related",
        "url": "http://eol.org/pages/10692652",
        "actionPlatform": [
          "http://schema.org/DesktopWebPlatform",
          "http://schema.org/IOSPlatform",
          "http://schema.org/AndroidPlatform"
        ]
      }
    },
    "sameAs": [
      "http://www.birdlife.org/datazone/speciesfactsheet.php?id=32678",
      "http://lod.taxonconcept.org/ses/voUQo.html",
      "http://www.iucnredlist.org/apps/redlist/details/22736309",
      "http://www.iucnredlist.org/apps/redlist/details/22736309",
      "http://en.wikipedia.org/w/index.php?title=Río_Orinoco_Spinetail"
    ],
    "vernacularNames": [
      {
        "@language": "en",
        "@value": "Rio Orinoco Spinetail",
        "gbif:isPreferredName": true
      }
    ],
    "traits": [

    ]
  }
}
rdmpage commented 8 years ago

The JSON shown above is the raw JSON-LD from EOL, below I've shown the edits needed to make it play nice with http://json-ld.org.

{ "@context": { "@vocab": "http://schema.org/", "dwc:taxonID": { "@type": "@id" }, "dwc:resourceID": { "@type": "@id" }, "dwc:relatedResourceID": { "@type": "@id" }, "dwc:relationshipOfResource": { "@type": "@id" }, "dwc:vernacularName": { "@container": "@language" }, "eol:associationType": { "@type": "@id" }, "rdfs:label": { "@container": "@language" }, "dc": "http://purl.org/dc/terms/", "dwc": "http://rs.tdwg.org/dwc/terms/", "eolterms": "http://eol.org/schema/terms/", "eol": "http://eol.org/schema/", "rdfs": "http://www.w3.org/2000/01/rdf-schema#", "gbif": "http://rs.gbif.org/terms/1.0/", "foaf": "http://xmlns.com/foaf/0.1/" }, "@type": "DataFeedItem", "dateModified": "2016-09-22", "item": { "@id": 10692652 "http://eol.org/pages/10692652", "@type": "dwc:Taxon", "scientificName": "Synallaxis beverlyae", "dwc:taxonRank": "species", "dwc:parentNameUsageID": "http://eol.org/pages/15003", "potentialAction": { "@type": "EntryPoint", "target": { "@type": "Related", "url": "http://eol.org/pages/10692652", "actionPlatform": [ "http://schema.org/DesktopWebPlatform", "http://schema.org/IOSPlatform", "http://schema.org/AndroidPlatform" ] } }, "sameAs": [ "http://www.birdlife.org/datazone/speciesfactsheet.php?id=32678", "http://lod.taxonconcept.org/ses/voUQo.html", "http://www.iucnredlist.org/apps/redlist/details/22736309", "http://www.iucnredlist.org/apps/redlist/details/22736309", "http://en.wikipedia.org/w/index.php?title=Río_Orinoco_Spinetail" ], "vernacularNames": [ { "@language": "en", "@value": "Rio Orinoco Spinetail", "gbif:isPreferredName": true } ], "traits": [

]

} }