JSON-LD总是将单个对象框架化为数组

时间:2017-03-14 10:16:20

标签: php arrays json json-ld easyrdf

有没有办法总是使用EasyRdf强制单个对象到数组?

如果有多个值为prod,我会得到一个像这样的数组。请注意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

序列化图表时,我向EasyRdf发送选项

{
    "@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"
    }]
}

有没有办法为'frame' => (object) [ '@context' => (object) [ 'ethon' => 'http://ethon.consensys.net/', 'ethstats' => 'http://ethereum.ethstats.io/', ], / @set属性发送rdf:type选项?

1 个答案:

答案 0 :(得分:0)

是的!当framing时,另外传递@context选项:

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

See it in use.
(单击 Flattened 和(返回) Framed 选项卡,如果由于某种原因在加载时显示不正确。)