如何在json-ld中指定一对多和多对一关系。 例如:
{
"@context" : {
"@vocab" : "http://www.schema.org/",
"@id" : "http://www.example.com/users/Joe",
"name" : "name",
"dob" : "birthDate",
"age" : {
"@id" : "http://www.example.com/users/Joe#age",
"@type" : "Number"
}
"knows" : ["http://www.example.com/users/Jill", "http://www.example.com/users/James"]
},
"name" : "Joe",
"age" : "24",
"dob" : "12-Jun-2013"
}
这不会在json-ld操场中解析。 在json-ld或使用Hydra?
指定这样的关系的有效和最佳方法是什么?答案 0 :(得分:1)
您需要对上下文中的内容以及放入文档正文中的内容充满信心。简单地说,上下文定义了URL的映射,而正文包含实际数据。因此,您的示例应如下所示:
{
"@context" : {
"@vocab" : "http://www.schema.org/",
"dob" : "birthDate",
"age" : {
"@id" : "http://www.example.com/users/Joe#age",
"@type" : "Number"
},
"knows": { "@type": "@id" }
},
"@id" : "http://www.example.com/users/Joe",
"name" : "Joe",
"age" : "24",
"dob" : "12-Jun-2013",
"knows" : [
"http://www.example.com/users/Jill",
"http://www.example.com/users/James"
]
}