在JSON-LD中,是否可以为属性值定义URI映射?

问题描述 投票:9回答:1

假设我们有以下JSON:

{
  "@context":
  {
    "name": "http://schema.org/name",
    "status": "http://schema.org/status"
  },
  "name": "Manu Sporny",
  "status": "trollin'"
}

(Qazxswpoi)

JSON-LD Playground状态用URI标识:trollin'。是否可以将上面示例中的http://example.com/trolling关键字扩展为URI trollin'

直接操作上下文不起作用:

http://example.com/trolling

(Qazxswpoi)

强制{ "@context": { "name": "http://schema.org/name", "status": "http://schema.org/status", "trollin'": "http://example.com/trolling" }, "name": "Manu Sporny", "status": "trollin'" } JSON Playground的类型也行不通,因为它假设status是相对URI。

@id

(Qazxswpoi)

json-ld
1个回答
7
投票

是的,你可以这样做,你需要将状态类型设置为@vocab:

trollin'

这是游乐场的{ "@context": { "name": "http://schema.org/name", "status": { "@id": "http://schema.org/status", "@type": "@id" }, "trollin'": "http://example.com/trolling" }, "name": "Manu Sporny", "status": "trollin'" }

© www.soinside.com 2019 - 2024. All rights reserved.