Any way to specify the default URI for the @id of a @type or the values of a property?

一笑奈何 提交于 2020-01-02 07:38:33

问题


(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?


回答1:


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.



来源:https://stackoverflow.com/questions/47397728/any-way-to-specify-the-default-uri-for-the-id-of-a-type-or-the-values-of-a-pro

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!