重用 JSON-LD 知识数据

Re-using JSON-LD knowledge data

我无法确定是否可以在定义对值后对其进行引用。

例如,如果我创建了一个地址对,我可以使用 shorthand 的方式重新使用该值吗?

"address": {
                        "@type": "PostalAddress",
                        "streetAddress": "14 Blue Street Road",
                        "addressLocality": "Nottingham",
                        "addressRegion": "Nottinghamshire
                        "postalCode": "NG73DT",
                        "addressCountry": "United Kingdom"
                    },
                    "foundingLocation": "@address",

是的,这是可能的。 JSON-LD 使用属性链接节点。节点要么是值对象(例如,日期、时间、数字等),要么是节点对象,例如上面的 PostalAddress。所有节点都有一个标识符,无论是显式的还是实现的,使用 @id 属性 指定。 JSON-LD Flattening 算法,除其他外,有一个过程,它删除嵌入的节点定义,并用引用替换它们,根据需要创建一个 空白节点 。引用基本上只是一个仅包含 @id 属性 的节点。可以通过向 PostalAddress 添加一个空白节点来重写上面的示例:

"address": {
                    "@id": "_:n1",
                    "@type": "PostalAddress",
                    "streetAddress": "14 Blue Street Road",
                    "addressLocality": "Nottingham",
                    "addressRegion": "Nottinghamshire
                    "postalCode": "NG73DT",
                    "addressCountry": "United Kingdom"
                },
                "foundingLocation": "@address",

然后您可以从 foundingLocation 引用它,如下所示:

"address": {
                    "@id": "_:n1",
                    "@type": "PostalAddress",
                    "streetAddress": "14 Blue Street Road",
                    "addressLocality": "Nottingham",
                    "addressRegion": "Nottinghamshire
                    "postalCode": "NG73DT",
                    "addressCountry": "United Kingdom"
                },
                "foundingLocation": {"@id": "_:n1"}