I'm trying to create a graph database for describing power systems and this is my first time using JSON-LD.
Steps so far:
- Created a schema according to the
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" }
CodePudding user response:
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" }