Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON-LD, is there any way to specify the default URI for the @id of a @type or the values of a property?

Tags:

uri

json-ld

(I've already asked this on the W3/JSON mailing list, I'll try here too.)

I'm fairly new to JSON-LD, although I have significant experience with Semantic Web technologies.

I've read the guideline document (https://www.w3.org/TR/json-ld/) and I haven't get if the feature at issue is supported:

Suppose you have JSON objects of @type Person and @type Address, both having the @id property. Typical API-coming data will have values like integers or some internal, context-dependant IDs. It's pretty common to RDF-translate those values to prefix-based URIs like http://www.example.com/Person/123 or http://www.example.com/Address/xh324m44.

What I would like to do is to specify those prefixes and keep data telling @id = '123', with the value joins happening at RDF serialisation stage (the same specification would make it possible to do the opposite conversion too). Clearly, in such a use case, the prefixes depend on the @type of objects, and the @base mechanism is not enough. Moreover, it would be useful to have this mechanism available for properties too, e.g., to associate the address URI prefix to the values of the "address" JSON property.

It doesn't seem that this is currently available in JSON-LD, or am I missing something? Any plan for future extensions?

like image 489
zakmck Avatar asked Nov 15 '25 05:11

zakmck


1 Answers

You can use @base in the context to create a URI base for values of @id, but this will not include something from @type. This sounds like something you might get by defining a URI template and using variables to expand type and id to create a URI. You can do this in a templating language and create the JSON-LD, but not directly in JSON-LD itself. Not likely to be a feature included by the language in the future, either, as it's application is pretty narrow.

like image 160
Gregg Kellogg Avatar answered Nov 17 '25 22:11

Gregg Kellogg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!