Klortho
Klortho

Reputation: 823

How to cleanly specify predicate-specific URI scopes in JSON-LD?

I'm starting with this JSON-LD document (json-ld playground), where the meat looks like this:

"from": [
  "protein:15718680",
  "protein:157427902"
],
"protein_gene": [
  "gene:522311",
  "gene:3702"
]

Now, the "protein_gene" predicate always takes gene identifiers as values. Since there can be hundreds of these, what I really want in the JSON is this:

"from": [ "protein:15718680", "protein:157427902" ], "protein_gene": [ "522311", "3702" ]

without the "gene" prefix everywhere. Is it possible? The closest I got, based on this SO question, was this (json-ld playground). It causes the predicate values to be expanded into IRIs, and not relative IRIs, but those based on the @vocab. But it is not right, because I want a predicate-specific vocab.

I also know that I can play tricks with embedded (local) contexts, and I got this (json-ld playground) to work, but it is still uglier than I would like.

Upvotes: 0

Views: 85

Answers (1)

Markus Lanthaler
Markus Lanthaler

Reputation: 3823

There are a couple of ways to do this for a single property, but not multiple (more than two, you can use @vocab and @base if you have two). Apart from injecting contexts, there's no way to scope @vocab and @base to a property.

Upvotes: 1

Related Questions