oeg-upm / DeltaCimApp

Apache License 2.0
1 stars 0 forks source link

Jena error parsing JSON-LD payloads #15

Closed AndreaCimminoArriaga closed 4 years ago

AndreaCimminoArriaga commented 4 years ago

The same payload is not parsed by Jena depending on how it is expressed, for instance the payload:

{
  "@context": {
    "FEID": {
      "@id": "core:FEID"
    },
    "Measurement": {
      "@id": "core:Measurement"
    },
    "PowerConsumption": {
      "@id": "core:PowerConsumption"
    },
    "VirtualNode": {
      "@id": "core:VirtualNode"
    },
    "core": "http://delta.linkeddata.es/def/core#",
    "hasTimeStamp": {
      "@id": "core:hasTimeStamp"
    },
    "hasValue": {
      "@id": "core:hasValue"
    },
    "isRelatedToProperty": {
      "@id": "core:isRelatedToProperty"
    },
    "makesMeasurement": {
      "@id": "core:makesMeasurement"
    },
    "manage": {
      "@id": "core:manage"
    },
    "om": "http://www.foodvoc.org/page/om-1.8/",
    "saref": "https://w3id.org/saref#",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "@graph": [
    {
      "@id": "dvn4",
      "@type": "VirtualNode",
      "manage": {
        "@id": "feidID406"
      }
    },
    {
      "@id": "feidID9PowerConsumption0",
      "@type": "Measurement",
      "hasTimeStamp": {
        "@type": "xsd:dateTime",
        "@value": "2020-07-03T14:24:00Z"
      },
      "hasValue": {
        "@type": "xsd:float",
        "@value": "72.54726"
      },
      "isRelatedToProperty": {
        "@id": "PowerConsumption"
      },
      "saref:isMeasuredIn": {
        "@id": "om:watt"
      }
    },
    {
      "@id": "feidID406",
      "@type": "FEID",
      "makesMeasurement": [
        {
          "@id": "feidID9PowerConsumption0"
        }
      ]
    }
  ]
}

is not parsed by Jena, producing an empty model. Nevertheless, this very same payload written as

[{"@id":"http://delta.linkeddata.es/def/core#FEID"},{"@id":"http://delta.linkeddata.es/def/core#Measurement"},{"@id":"http://delta.linkeddata.es/def/core#VirtualNode"},{"@id":"http://njh.me/PowerConsumption"},{"@id":"http://njh.me/dvn4","@type":["http://delta.linkeddata.es/def/core#VirtualNode"],"http://delta.linkeddata.es/def/core#manage":[{"@id":"http://njh.me/feidID406"}]},{"@id":"http://njh.me/feidID406","@type":["http://delta.linkeddata.es/def/core#FEID"],"http://delta.linkeddata.es/def/core#makesMeasurement":[{"@id":"http://njh.me/feidID9PowerConsumption0"}]},{"@id":"http://njh.me/feidID9PowerConsumption0","@type":["http://delta.linkeddata.es/def/core#Measurement"],"http://delta.linkeddata.es/def/core#hasTimeStamp":[{"@value":"2020-07-03T14:24:00Z","@type":"http://www.w3.org/2001/XMLSchema#dateTime"}],"http://delta.linkeddata.es/def/core#hasValue":[{"@value":"72.54726","@type":"http://www.w3.org/2001/XMLSchema#float"}],"http://delta.linkeddata.es/def/core#isRelatedToProperty":[{"@id":"http://njh.me/PowerConsumption"}],"https://w3id.org/saref#isMeasuredIn":[{"@id":"http://www.foodvoc.org/page/om-1.8/watt"}]},{"@id":"http://www.foodvoc.org/page/om-1.8/watt"}]

is parsed correctly

AndreaCimminoArriaga commented 4 years ago

This issue has been solved. Jena is not able to parse the first payload because it lacks of URIs as subjects, notice the "@id" : "dvn". However, Jena usually fires an error to war the user and in this case it does not.