Parsing JSON-LD帧:强制重复冗余属性值

Parsing JSON-LD帧:强制重复冗余属性值,parsing,json-ld,Parsing,Json Ld,是否可以强制复制冗余属性值,例如author和creator 目标是减少以后额外的解析,并拥有一个易于遍历的JSON对象,而不管重复的值是什么 样本: { “@type”:“新闻文章”, “文章正文”:“文章正文”, “作者”:{ “id”:“\uB1:b1” }, “创造者”:{ “id”:“\uB1”, “类型”:“人”, “名称”:“创建者名称”, “url”:”https://example.org/author/creator-name/" }, “说明”:“说明”, “标题”:“标题

是否可以强制复制冗余属性值,例如
author
creator

目标是减少以后额外的解析,并拥有一个易于遍历的JSON对象,而不管重复的值是什么

样本:

{
“@type”:“新闻文章”,
“文章正文”:“文章正文”,
“作者”:{
“id”:“\uB1:b1”
},
“创造者”:{
“id”:“\uB1”,
“类型”:“人”,
“名称”:“创建者名称”,
“url”:”https://example.org/author/creator-name/"
},
“说明”:“说明”,
“标题”:“标题”
}
框架:

{
“@context”:”https://schema.org/docs/jsonldcontext.json",
“@vocab”:”https://schema.org",
“@type”:[“文章”、“新闻文章”、“科技文章”、“学术文章”],
“作者”:{
“@type”:”http://schema.org/Person",
@embed:“true”
}
}
预期结果:

{
“@type”:“新闻文章”,
“文章正文”:“文章正文”,
“作者”:{
“id”:“\uB1”,
“类型”:“人”,
“名称”:“创建者名称”,
“url”:”https://example.org/author/creator-name/"
},
“创造者”:{
“id”:“\uB1”,
“类型”:“人”,
“名称”:“创建者名称”,
“url”:”https://example.org/author/creator-name/"
},
“说明”:“说明”,
“标题”:“标题”
}

要重复节点,您需要使用
“@embed”:“@always”
。试试看

输入:

{
“@context”:”https://schema.org/docs/jsonldcontext.json",
“@type”:“新闻文章”,
“文章正文”:“文章正文”,
“作者”:{
“id”:“\uB1:b1”
},
“创造者”:{
“id”:“\uB1”,
“类型”:“人”,
“名称”:“创建者名称”,
“url”:”https://example.org/author/creator-name/"
},
“说明”:“说明”,
“标题”:“标题”
}
框架:

{
“@context”:”https://schema.org/docs/jsonldcontext.json",
“@type”:[“文章”、“新闻文章”、“科技文章”、“学术文章”],
“作者”:{
“@embed”:“@始终”
},
“创造者”:{
“@embed”:“@始终”
}
}
结果:

{
“@context”:”https://schema.org/docs/jsonldcontext.json",
“@graph”:[
{
“类型”:“新闻文章”,
“文章正文”:“文章正文”,
“作者”:{
“id”:“\uB1”,
“类型”:“人”,
“名称”:“创建者名称”,
“url”:”https://example.org/author/creator-name/"
},
“创造者”:{
“id”:“\uB1”,
“类型”:“人”,
“名称”:“创建者名称”,
“url”:”https://example.org/author/creator-name/"
},
“说明”:“说明”,
“标题”:“标题”
}
]
}