Network Working Group E. Pot
Internet-Draft
Intended status: Standards Track G. Sullice
Expires: July 12, 2020 Acquia, Inc.
January 09, 2020
JSON serialization for Web Linking
draft-pot-json-link-01
Abstract
This specification defines a serialization of Web Linking [RFC8288]
in the JSON [RFC8259] format.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on July 12, 2020.
Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Pot & Sullice Expires July 12, 2020 [Page 1]
Internet-Draft JSON serialization for Web Linking January 2020
1. Introduction
There are many JSON-based standards and formats that require the need
to express a link. Examples can be found in [draft-kelly-json-hal],
[JSON-API], [WEBTHING], [draft-nottingham-json-home],
[COLLECTIONJSON], [SIREN] and many others.
Because there hasn't been an accepted reference for serializing Web
Links in JSON, it's typical for authors of new formats to invent
their own. This has resulted in many minor differences between
serializations, making it difficult to write generic parsers.
This document is an attempt to define a standard JSON serialization
for Web linking. A primary goal is to define a format that's
relatively uncontroversial and similar to existing serializations.
Furthermore, this specification defines an optional format for groups
of links and a recommendation for defining document-wide links.
2. Format
2.1. The link object.
A link will be encoded as a JSON [RFC8259] object. The object might
support the properties from the following chapters, but only "rel"
and "href" are required.
The "rel" property refers to Section 3.3 of [RFC8288]. The "rel"
property must be a string.
There is no support to encode multiple relation types for a single
link. To encode multiple relation types, the link must appear
multiple times in the document.
The "href" property refers to the Link Target, defined in Section 3.1
of [RFC8288].
The property is required and must be specified as a string.
The "anchor" attribute is defined in Section 3.2 of [RFC8288]. This
specification alters the behavior of anchor. By default, if anchor
Pot & Sullice Expires July 12, 2020 [Page 2]
Internet-Draft JSON serialization for Web Linking January 2020
is not specified the link context is considered to be the URL of the
representation it is associated with.
If the link appears alongside a link with the 'self' relation type
(for example in Section 2.2 of links, the target of the self link
MUST be used as the default link context, unless the anchor attribute
is defined.
If the link is not part of a list of links that has a link relation
of type 'self', the default behavior is to use the URL of the
representation it's associated with.
However, implementors of this specification MAY override this.
Because JSON links may have deeper contextual meaning depending on
where it appears in the document.
2.1.4. Other attributes
The link object may also encode the "hreflang", "media", "type"
attributes. These properties are all defined in Section 3.4.1 of
[RFC8288]. In their JSON serialization they are all optional, and
must be encoded as a string.
Section 3.4.1 also defines a "title*" attribute, which may contain an
alternative encoding for the "title" attribute.
JSON only supports UTF-8 encoding. As such, it is not needed to make
this distinction. The link title is always encoded using the "title"
property.
2.1.5. Extension Attributes
Similar to [RFC8288], other documents may define new target
attributes for links. Parsers that don't understand any attributes
appearing on a link MUST ignore them.
This section is non-normative.
{
"href": "https://evertpot.com/",
"rel": "author",
"title": "Evert Pot"
}
Pot & Sullice Expires July 12, 2020 [Page 3]
Internet-Draft JSON serialization for Web Linking January 2020
2.2. Lists of links
Authors that wish to encode a set of links in a document, SHOULD use
an array of links.
This section is non-normative.
[
{
"href": "https://evertpot.com/",
"rel": "author",
"title": "Evert Pot"
},
{
"href": "https://test.example/",
"rel": "self"
}
}
2.3. Document-level links
If a JSON representation wants to define document-level links,
implementors of this specification SHOULD use a top-level "links"
property to define these.
The "links" property contains a list of links.
The links appearing in this list are considered semantically
equivalent to the links appear in the "Link" header, as defined in
Section 3.5 of [RFC8288].
Implementors of this specification MAY make an effort to expose links
from the HTTP Link header and the document-level links via a unified
interface.
This section is non-normative.
Pot & Sullice Expires July 12, 2020 [Page 4]
Internet-Draft JSON serialization for Web Linking January 2020
{
"links": [
{
"href": "https://evertpot.com/",
"rel": "author",
"title": "Evert Pot"
},
{
"href": "https://test.example/",
"rel": "self"
}
]
}
3. IANA considerations
We would like to register the 'application/links+json' media-type for
documents wishing to implement this spec.
TBD?
4. References
4.1. Normative References
[RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", STD 90, RFC 8259,
DOI 10.17487/RFC8259, December 2017,
<https://www.rfc-editor.org/info/rfc8259>.
[RFC8288] Nottingham, M., "Web Linking", RFC 8288,
DOI 10.17487/RFC8288, October 2017,
<https://www.rfc-editor.org/info/rfc8288>.
4.2. Informative References
[COLLECTIONJSON]
Mike Amundsen, ., "Collection+JSON", n.d.,
<http://amundsen.com/media-types/collection/format/>.
[draft-kelly-json-hal]
Kelly, M., "JSON Hypertext A:wpplication Language", n.d.,
<https://tools.ietf.org/html/draft-kelly-json-hal>.
[draft-nottingham-json-home]
Nottingham, M., "Home Documents for HTTP APIs", n.d.,
<https://tools.ietf.org/html/draft-nottingham-json-home>.
Pot & Sullice Expires July 12, 2020 [Page 5]
Internet-Draft JSON serialization for Web Linking January 2020
[JSON-API]
"JSON:API", n.d., <https://jsonapi.org/format/>.
[SIREN] Kevin Swiber, ., "Siren: a hypermedia specification for
representing entities", n.d.,
<https://github.com/kevinswiber/siren>.
[WEBTHING]
Ben Francis, ., "Web Thing API", n.d.,
<https://iot.mozilla.org/wot/>.
Appendix A. Typescript definitions
type Link = {
href: string,
rel: string,
anchor?: string,
hreflang?: string,
media?: string,
type?: string,
}
type LinkSet = Link[];
type DocumentLinks = {
links: LinkSet
}
Appendix B. JSON-SCHEMA definitions
Pot & Sullice Expires July 12, 2020 [Page 6]
Internet-Draft JSON serialization for Web Linking January 2020
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "...",
"type": "object",
"additionalProperties": true,
"required": [
"href",
"rel"
],
"properties": {
"href": {
"type": "string",
"format":"uri-reference"
},
"rel": {
"type": "string",
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"hreflang": {
"type": "string",
},
"media": {
"type": "string"
}
}
}
C.1. Changes since -??
Authors' Addresses
Evert Pot
Email: me@evertpot.com
URI: https://evertpot.com/
Pot & Sullice Expires July 12, 2020 [Page 7]
Internet-Draft JSON serialization for Web Linking January 2020
Gabriel Sullice
Acquia, Inc.
Email: gabriel@sullice.com
URI: https://sullice.com
Pot & Sullice Expires July 12, 2020 [Page 8]