JSON-LD,有没有办法为@type 的@id 或属性值指定默认URI? [英] JSON-LD, is there any way to specify the default URI for the @id of a @type or the values of a property?

查看:29
本文介绍了JSON-LD,有没有办法为@type 的@id 或属性值指定默认URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我已经在 W3/JSON 邮件列表中询问过这个问题,我也会在这里尝试.)

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

我对 JSON-LD 还很陌生,尽管我在语义 Web 技术方面拥有丰富的经验.

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

我已阅读指南文件(https://www.w3.org/TR/json-ld/),我不知道是否支持有问题的功能:

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:

假设您有 @type Person@type Address 的 JSON 对象,它们都具有 @id 属性.典型的 API 传入数据将具有诸如整数或一些内部的、依赖于上下文的 ID 之类的值.RDF 将这些值转换为基于前缀的 URI 是很常见的,比如 http://www.example.com/Person/123http://www.example.com/Address/xh324m44.

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.

我想做的是指定这些前缀并保持数据告诉 @id = '123',值连接发生在 RDF 序列化阶段(相同的规格也可以进行相反的转换).显然,在这样的用例中,前缀取决于对象的@type,而@base 机制是不够的.此外,让这种机制也可用于属性也会很有用,例如,将地址 URI 前缀与地址"JSON 属性的值相关联.

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.

目前 JSON-LD 中似乎没有这个功能,还是我遗漏了什么?未来有扩展计划吗?

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

推荐答案

您可以在上下文中使用 @base@id 的值创建一个 URI 基础,但这不会包括来自 @type 的内容.这听起来像是通过定义一个 URI 模板并使用变量来扩展 type 和 id 来创建一个 URI 可能会得到的东西.您可以使用模板语言执行此操作并创建 JSON-LD,但不能直接在 JSON-LD 本身中创建.将来也不太可能成为该语言包含的功能,因为它的应用范围非常狭窄.

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.

这篇关于JSON-LD,有没有办法为@type 的@id 或属性值指定默认URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆