JSON-LD始终将单个对象作为数组进行框架化

3
有没有办法通过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选项?
1个回答

0

是的!当构建框架时,还需传递@context选项:

"@context": {
    ...
    "@type": {"@container": "@set"}
}

查看使用情况。
(如果由于某种原因无法正确加载,请单击平铺和(返回)框架选项卡。)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接