Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从框架JSON-LD中删除额外参数 ,让我们考虑从Db:< /P>获取的下列数据 [ { "@id": "http://example.com/1", "http://example.com/label": "Parent", "http://example.com/status": "Active", "http://example.com/children": [ { "@id": "http://example.com/2" } ] }, { "@id": "http://example.com/2", "http://example.com/label": "Child", "http://example.com/status": "Active" } ]_Json_Rdf_Semantic Web_Json Ld - Fatal编程技术网

从框架JSON-LD中删除额外参数 ,让我们考虑从Db:< /P>获取的下列数据 [ { "@id": "http://example.com/1", "http://example.com/label": "Parent", "http://example.com/status": "Active", "http://example.com/children": [ { "@id": "http://example.com/2" } ] }, { "@id": "http://example.com/2", "http://example.com/label": "Child", "http://example.com/status": "Active" } ]

从框架JSON-LD中删除额外参数 ,让我们考虑从Db:< /P>获取的下列数据 [ { "@id": "http://example.com/1", "http://example.com/label": "Parent", "http://example.com/status": "Active", "http://example.com/children": [ { "@id": "http://example.com/2" } ] }, { "@id": "http://example.com/2", "http://example.com/label": "Child", "http://example.com/status": "Active" } ],json,rdf,semantic-web,json-ld,Json,Rdf,Semantic Web,Json Ld,和框架: { "@context": { "@base": "http://example.com/", "@vocab": "http://example.com/" }, "@graph": { "status":{} } } 结果如下所示: { "@context": { &qu

和框架:

{
  "@context": {
    "@base": "http://example.com/",
    "@vocab": "http://example.com/"
  },
  "@graph": {
    "status":{}
  }
}
结果如下所示:

{
  "@context": {
    "@base": "http://example.com/",
    "@vocab": "http://example.com/"
  },
  "@graph": [
    {
      "@id": "1",
      "children": {
        "@id": "2",
        "label": "Child",
        "status": "Active"
      },
      "label": "Parent",
      "status": "Active"
    },
    {
      "@id": "2",
      "label": "Child",
      "status": "Active"
    }
  ]
}
正如您在第一个对象中所看到的,在
子对象
部分,除了id之外,我还获得了一些额外的参数

是否有一种方法可以简化
子项
列表以仅包含ID:

"children": [
    "2"
]
我尝试将此添加到我的框架中:

"children": {
  "@id": "http://example.com/children",
  "@type": "@id"
}
但是它没有像我期望的那样工作。

使用:
“@embed”:“@never”
“@explicit”:true

{
  "@context": {
    "@base": "http://example.com/",
    "@vocab": "http://example.com/"
  },
  "@graph": {
    "status": {},
    "@embed": "@never"
  }
}

但也许你所需要的只是

如果不想压缩阵列,请切换相应的。在JSONLD Java中:

final JsonLdOptions=new JsonLdOptions();
options.setCompactArray(false);

操场:

{
  "@context": {
    "@base": "http://example.com/",
    "@vocab": "http://example.com/"
  },
  "@graph": {
    "status": {},
    "children": {"@explicit": true, "@omitDefault": true}
  }
}