有没有一种方法可以使用EasyRdf始终强制单个对象到数组中?
如果有多个值作为rdf:type,我会得到一个类似下面这样的数组。注意:@type属性是一个数组。
{
"@context": {
"ethon": "http://ethon.consensys.net/",
"ethstats": "http://ethereum.ethstats.io/"
},
"@graph": [{
"@id": "ethstats:Uncle_0x5cd50096dbb856a6d1befa6de8f9c20decb299f375154427d90761dc0b101109",
"@type": ["ethon:Uncle", "ethon:Block"],
"ethon:blockCreationTime": "2015-07-30T15:26:58.000Z",
"ethon:blockHash": "0x5cd50096dbb856a6d1befa6de8f9c20decb299f375154427d90761dc0b101109",
"ethon:number": "1"
}]
}但如果只有一个rdf:type,则@type属性不是数组。
{
"@context": {
"ethon": "http://ethon.consensys.net/",
"ethstats": "http://ethereum.ethstats.io/"
},
"@graph": [{
"@id": "ethstats:Uncle_0x5cd50096dbb856a6d1befa6de8f9c20decb299f375154427d90761dc0b101109",
"@type": "ethon:Uncle",
"ethon:blockCreationTime": "2015-07-30T15:26:58.000Z",
"ethon:blockHash": "0x5cd50096dbb856a6d1befa6de8f9c20decb299f375154427d90761dc0b101109",
"ethon:number": "1"
}]
}在序列化图形时,我将选项发送给EasyRdf
'frame' => (object) [
'@context' => (object) [
'ethon' => 'http://ethon.consensys.net/',
'ethstats' => 'http://ethereum.ethstats.io/',
],有没有办法为rdf:type / @type属性发送@set选项?
发布于 2020-12-15 21:54:57
是!如果为framing,则额外传递@context选项:
"@context": {
...
"@type": {"@container": "@set"}
}(如果由于某种原因在加载时不能正确显示,请单击扁平化和(返回到)边框选项卡。)
https://stackoverflow.com/questions/42783190
复制相似问题