【问题标题】:How to compact an @id?如何压缩@id?
【发布时间】:2021-10-06 11:34:10
【问题描述】:

是否可以通过上下文在@id 中压缩鸢尾花? 如果不使用@base,我没有找到解决方案。

    {
      "@context":  {
        "MaxMustermann": "http://example.org/MaxMustermann",
        "name": "https://schema.org/name"
      },
      "@id": "MaxMustermann",
      "name": "Max Mustermann"
    }

最好的问候

【问题讨论】:

    标签: rdf owl json-ld rdfs linked-data


    【解决方案1】:

    您可以使用由前缀和后缀组成的符号将您的@id 写为compact IRI。前缀在您的@context 中定义。 看看这个输入:

    {
      "@context": {
        "ex": "http://example.org/",
        "foaf": "http://xmlns.com/foaf/0.1/"
      },
      "@type": "foaf:Person",
      "@id":"ex:MaxMustermann"
    }
    

    这转化为这个扩展的定义:

    [
      {
        "@id": "http://example.org/MaxMustermann",
        "@type": [
          "http://xmlns.com/foaf/0.1/Person"
        ]
      }
    ]
    

    您也可以在JSON-LD playground 上查看此示例。 如您所见,前缀ex 用于缩写@id IRI 的命名空间。 @type 也是如此,其中使用了前缀 foaf。 这是你要找的吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-12
      • 2019-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多