user6454026 user6454026 - 8 months ago 41
JSON Question

IRI Mapping and referencing in JSON-LD

I am trying to design an ontology using JSON-LD but i'm having trouble getting the syntax right. I looked at but couldn't find exactly the piece of information I am looking for, which is this: How to nest IRI's in the context, and how to reference them in the body?

"@id": "instances:1",
"@type": "Plant",
"plants:numleaves": "8",
"plants:speciesname": "sunflower"
"@id": "instances:2",
"@type": "Animal",
"animals:numlegs": "4",
"animals:speciesname": "dog",
"animals:eats": "instances:1"

I want the id of the first element to be
, but when I run it through , it's expanded form is
. How do I make it right?


It doesn't work the way you want, because you define @base and then try to use it as a prefix.

Also the hash (#) won't just magically appear. You must include it in your base URI.

To sum up you would have to change your context to:


Now instances:1 is a concatenation of + instances# + 1 as you ask for.