简体   繁体   English

JSON-LD框架具有可选属性?

[英]JSON-LD framing with optional properties?

How to define some properties as "optional" in JSON-LD context? 如何在JSON-LD上下文中将某些属性定义为“可选”?

I created simple example of the problem. 我创建了问题的简单示例。 Here is the same example in JSON-LD Playground . 这是JSON-LD Playground中的相同示例 This is the example data: 这是示例数据:

{
  "@context": {
    "ex": "http://example.org/ex#",
    "foaf": "http://xmlns.com/foaf/0.1/",
    "frapo": "http://purl.org/cerif/frapo/",
    "owl": "http://www.w3.org/2002/07/owl#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "@graph": [
    {
      "@id": "ex:Organization_1",
      "@type": "foaf:Organisation",
      "foaf:member": [
        {
          "@id": "ex:Person_1"
        },
        {
          "@id": "ex:Person_2"
        }
      ],
      "frapo:funds": [
        {
          "@id": "ex:Project_1"
        },
        {
          "@id": "ex:Project_2"
        }
      ]
    },
    {
      "@id": "ex:Person_2",
      "@type": "foaf:Person",
      "foaf:currentProject": {
        "@id": "ex:Project_2"
      },
      "foaf:name": "Jack"
    },
    {
      "@id": "ex:Project_2",
      "@type": "foaf:Project",
      "foaf:name": "Small project 2"
    },
    {
      "@id": "ex:Project_1",
      "@type": "foaf:Project",
      "foaf:name": "Big project 1"
    },
    {
      "@id": "ex:Person_1",
      "@type": "foaf:Person",
      "foaf:name": "Bill",
      "foaf:pastProject": [
        {
          "@id": "ex:Project_1"
        },
        {
          "@id": "ex:Project_2"
        }
      ]
    }
  ]
}

I want the Organisation to be the main node, such as: 我希望组织成为主要节点,例如:

foaf:Organisation FOAF:组织

  • member: [{Person}, {Person}] 成员:[{Person},{Person}]

  • funds: [{Project}, {Project}] 资金:[{Project},{Project}]

In order to create such stucture i created frame: 为了创建这样的结构,我创建了框架:

{
 "@context": {
  "ex": "http://example.org/ex#",
  "foaf": "http://xmlns.com/foaf/0.1/",
  "owl": "http://www.w3.org/2002/07/owl#",
  "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
  "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
  "xsd": "http://www.w3.org/2001/XMLSchema#",
  "frapo": "http://purl.org/cerif/frapo/"
},
"@type": "foaf:Organisation",
"foaf:member": {
"foaf:currentProject": {
  "@embed": false
},
"foaf:pastProject": {
  "@embed": false
 }
},
"frapo:funds": {}
}

Now the problem is that foaf:member turns out to be "null", and if you remove those project relationships projects get embedded in the Person instances. 现在问题是foaf:成员变成了“null”,如果删除那些项目关系,项目就会嵌入到Person实例中。

Try it with this frame instead: 请尝试使用此框架:

{
    "@context": {
        "ex": "http://example.org/ex#",
        "foaf": "http://xmlns.com/foaf/0.1/",
        "owl": "http://www.w3.org/2002/07/owl#",
        "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "frapo": "http://purl.org/cerif/frapo/"
    },
    "@type": "foaf:Organisation",
    "foaf:member": {
        "foaf:currentProject": {
            "@default": [],
            "@embed": false
        },
        "foaf:pastProject": {
            "@default": [],
            "@embed": false
        }
    },
    "frapo:funds": {}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM