4.2. Links (链接)
4.2. Links (链接)
"links" 数组在数据结构中用于表示指向互联网上其他资源的链接。这些链接的关系由 [RFC8288] 描述的 IANA 注册表定义。
以下是链接结构的示例:
{
"value" : "https://example.com/context_uri",
"rel" : "self",
"href" : "https://example.com/target_uri",
"hreflang" : [ "en", "ch" ],
"title" : "title",
"media" : "screen",
"type" : "application/json"
}
"rel", "href", "hreflang", "title", "media" 和 "type" 的 JSON 名称/值对应于 [RFC8288] 第 3 节中找到的值。"value" JSON 值是 [RFC8288] 描述的上下文 URI。"value", "rel" 和 "href" JSON 值必须被指定。所有其他 JSON 值是可选的。"related" 链接关系不能包含与 "self" 链接关系 "href" URI 相同的 "href" URI, 以降低客户端处理无限循环的风险。URI 中返回的国际化域名 (Internationalized Domain Names, IDNs) 应该一致地以 LDH 名称格式返回, 以允许客户端根据其能力处理这些 IDNs。
这是 "links" 数组在对象类中可能出现的示例:
"links" :
[
{
"value" : "https://example.com/ip/2001:db8::123",
"rel" : "self",
"href" : "https://example.com/ip/2001:db8::123",
"type" : "application/rdap+json"
},
{
"value" : "https://example.com/ip/2001:db8::123",
"rel" : "up",
"href" : "https://example.com/ip/2001:db8::/48",
"type" : "application/rdap+json"
}
]