JSON-LD帧单个对象数组 [英] JSON-LD framing single object arrays
问题描述
有没有办法强制单个对象到一个数组?这实在是烦人,每次测试对象类型。
我试过这样的背景下,但它不工作。还有一个在JSON-LD游乐场 例子。有了这个背景下的资源都变成了单一的对象和包含一个对象不阵列,你所期望的。
{
@context:{
成员:{
@id:http://xmlns.com/foaf/0.1/member,
@container:@list
},
恩:http://example.org/ex#
FOAF:http://xmlns.com/foaf/0.1/,
猫头鹰: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:组织,
成员:[]
}
结果:
... {
@id:例如:Organization_1
@type:FOAF:组织,
FOAF:成员:{
@id:例如:PERSON_1
@type:FOAF:人,
FOAF:名:条例
}
} ...
和它应该是什么:
FOAF:成员:[{@id:...}]
使用@容器:@set
而不是 @list
。
@list
意味着秩序 - 和 @set
没有。 JFYI,它压缩数据时可能是您的会员一词没有被选中(由算法),因为你的输入不匹配 @list
。如果您的数据不匹配的情况下,另一种术语,确实匹配(或完整URL)的任期将被使用。总之,使用 @set
代替。
Is there a way to force single objects to an array? It is really annoying to test object type every time.
I tried this context, but it doesnt work. There is also example in JSON-LD Playground. With this context resources are turned into single objects and not array containing one object, as you would expect.
{
"@context": {
"member": {
"@id": "http://xmlns.com/foaf/0.1/member",
"@container": "@list"
},
"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",
"member": []
}
Result:
... {
"@id": "ex:Organization_1",
"@type": "foaf:Organisation",
"foaf:member": {
"@id": "ex:Person_1",
"@type": "foaf:Person",
"foaf:name": "Bill"
}
} ...
And what it should be:
"foaf:member": [{ "@id": ... }]
Use "@container": "@set"
instead of @list
.
@list
implies order -- and @set
does not. JFYI, it's possible that your "member" term is not being selected (by the algorithm) when compacting your data because your input does not match a @list
. If your data doesn't match a term in your context, an alternative term that does match (or the full url) will be used. In short, use @set
instead.
这篇关于JSON-LD帧单个对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!