JSON-LD扩展

q7solyqu  于 2023-08-08  发布在  其他
关注(0)|答案(1)|浏览(111)

JSON-LD Playground(一个示例JSON-LD处理器)不会像这样用“compact IRI”(“example:dog”)扩展内容(属性值):

{
  "@context": {
    "example": "https://example.com/vocab#"
  },
  "animal": "example:dog"
}

字符串
这个完整的IRI(“https://example.com/vocab#dog”):

{
  "@context": {
    "example": "https://example.com/vocab#"
  },
  "animal": "https://example.com/vocab#dog"
}


这是我使用的特定JSON-LD处理器的故障吗?或者这是我(和ChatGPT's)对使用@context的JSON-LD扩展的误解?

pod7payv

pod7payv1#

@IS4是对的。当我使用SKOS cat and dog Concepts创建一个带有SKOS animal Collection的JSON-LD示例时...

{
  "@context": {
    "skos": "http://www.w3.org/2004/02/skos/core#",
    "example": "https://example.com/vocab#"
  },
  "@graph": [
    {
      "@id": "example:animals_collection",
      "@type": "skos:Collection",
      "skos:member": [
        {
          "@id": "example:cat",
          "@type": "skos:Concept",
          "skos:prefLabel": "Cat"
        },
        {
          "@id": "example:dog",
          "@type": "skos:Concept",
          "skos:prefLabel": "Dog"
        }         
      ]
    }
  ]
}

字符串
... JSON-LD Expansion是我想要的,即@id属性反映了集合的扩展IRI以及SKOS集合的每个成员(狗,猫)(以压缩格式显示):

{
  "@id": "https://example.com/vocab#animals_collection",
  "@type": "http://www.w3.org/2004/02/skos/core#Collection",
  "http://www.w3.org/2004/02/skos/core#member": [
    {
      "@id": "https://example.com/vocab#cat",
      "@type": "http://www.w3.org/2004/02/skos/core#Concept",
      "http://www.w3.org/2004/02/skos/core#prefLabel": "Cat"
    },
    {
      "@id": "https://example.com/vocab#dog",
      "@type": "http://www.w3.org/2004/02/skos/core#Concept",
      "http://www.w3.org/2004/02/skos/core#prefLabel": "Dog"
    }
  ]
}

相关问题