1

I'm trying to create a graph database for describing power systems and this is my first time using JSON-LD.

Steps so far:

The issue I'm facing is that my schema seems to be accepted (changing it creates an error) but no output is shown and no explanation is provided. Any help to work out what I'm missing would be much appreciated.

enter image description here

Schema

{
  "$id": "https://osuked.github.io/Power-Station-Dictionary/power-station",

  "type": "object",
  "properties": {
    "capacity": { "type": "float" },
    "fuel-type": { "type": "string" }
  },
  "required": ["capacity", "fuel-type"]
}

Example object instance

{
  "@context": "https://osuked.github.io/Power-Station-Dictionary/power-station.json",
  "@id": "http://osuked.github.io/Drax",
  "capacity": 12,
  "fuel-type": "wind"
}

1 Answer 1

2

Check the definition of the context (https://json-ld.org/spec/latest/json-ld/#the-context). It must specify how your properties (capacity and fuel-type) map to RDF properties. You can either provide the definitions inline or point to a URL that contains this mapping (e.g. https://schema.org/docs/jsonldcontext.jsonld).

In your example, you provide the URL https://osuked.github.io/Power-Station-Dictionary/power-station.json. It contains a JSON document but does not contain the JSON-LD context, because JSON Schema != JSON LD (you might find this article helpful to understand the difference: https://dashjoin.medium.com/json-schema-schema-org-json-ld-whats-the-difference-e30d7315686a).

Therefore, the JSON LD playground does not show an error (no property definitions found) but also shows no parsed triples.

To fix this, you can try using "@context": "http://schema.org/", you can define a namespace prefix p,

{
  "@context": {
    "p": "https://osuked.github.io/Power-Station-Dictionary/power-station/"
  },
  "@id": "http://osuked.github.io/Drax",
  "p:capacity": 12,
  "p:fuel-type": "wind"
}

or define the properties individually:

{
  "@context": {
    "capacity": "https://osuked.github.io/Power-Station-Dictionary/power-station/capacity",
    "fuel-type": "https://osuked.github.io/Power-Station-Dictionary/power-station/fuel-type"
  },
  "@id": "http://osuked.github.io/Drax",
  "capacity": 12,
  "fuel-type": "wind"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.