如何在 JSON-LD 中编写循环 RDF 图?
How can I write a cyclic RDF graph in JSON-LD?
我的图表如下:
[Natasha]--- knows--> [Bob]
[Bob]--- brother of--> [Alice]
[Alice]--- play with--> [Natasha]
如何将它嵌入 JSON-LD?
我当前的解决方案不起作用:
{
"@context" : {
"Natasha" : "http://names.example.org/resource/name/Natasha",
"Bob" : "http://names.example.org/resource/name/Bob",
"Alice" : "http://names.example.org/resource/name/Alice",
"knows" : "http://example.com/knows",
"brother-of" : "http://example.com/brother-of",
"play-with" : "http://example.com/play-with"
},
"@id" : "Natasha",
"knows" :
{ "@id" : "Bob",
"brother-of" : {
"@id" : "Alice",
"play-with" : "Natasha"
}
}
}
此值被解释为纯文本,而不是 URI:
"play-with" : "Natasha"
要将其解释为 URI,您可以在上下文中定义它:
"@context": {
"play-with": {
"@id": "http://example.com/play-with",
"@type": "@id"
}
}
或者您可以在提供值时明确说明(就像您已经为 brother-of
所做的那样):
"play-with" : {"@id": "Natasha"}
我的图表如下:
[Natasha]--- knows--> [Bob]
[Bob]--- brother of--> [Alice]
[Alice]--- play with--> [Natasha]
如何将它嵌入 JSON-LD?
我当前的解决方案不起作用:
{
"@context" : {
"Natasha" : "http://names.example.org/resource/name/Natasha",
"Bob" : "http://names.example.org/resource/name/Bob",
"Alice" : "http://names.example.org/resource/name/Alice",
"knows" : "http://example.com/knows",
"brother-of" : "http://example.com/brother-of",
"play-with" : "http://example.com/play-with"
},
"@id" : "Natasha",
"knows" :
{ "@id" : "Bob",
"brother-of" : {
"@id" : "Alice",
"play-with" : "Natasha"
}
}
}
此值被解释为纯文本,而不是 URI:
"play-with" : "Natasha"
要将其解释为 URI,您可以在上下文中定义它:
"@context": {
"play-with": {
"@id": "http://example.com/play-with",
"@type": "@id"
}
}
或者您可以在提供值时明确说明(就像您已经为 brother-of
所做的那样):
"play-with" : {"@id": "Natasha"}