From 0448899e44cdade0b08655dd06b2b2b59bd4b0d3 Mon Sep 17 00:00:00 2001 From: Kalle Tuure Date: Fri, 6 Mar 2015 03:15:44 +0200 Subject: [PATCH 1/3] Explain complex attributes --- format/index.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/format/index.md b/format/index.md index 250023f96..45d97d788 100644 --- a/format/index.md +++ b/format/index.md @@ -144,6 +144,9 @@ In addition, a resource object **MAY** contain any of these top-level members: Any other top-level member in a resource object represents an "attribute". An attribute may contain any valid JSON value. +If the value of an attribute is a JSON object or array, the member is called +a [complex attribute](#document-structure-complex-attrs). + Although has-one foreign keys (e.g. `author_id`) are often stored internally alongside other information to be represented in a resource object, these keys *SHOULD NOT* appear as attributes. If relations are provided, they **MUST** @@ -333,6 +336,47 @@ relationship as a string value rather than an object, is equivalent: // ... ``` +#### Complex Attributes + +The value of a complex attribute is allowed to be any valid JSON structure. + +Complex attributes **MAY** contain references to resources. The relationships +are represented in the same way as links on resource objects. Therefore, any +JSON object in a complex attribute must reserve the `links` member to hold +relationship information. + +For example, a representation of a `people` resource might include an array of +addresses embedded as a complex attribute: + +```json +{ + "type": "people", + "id": "789", + "name": "Victor Shiroyama", + "addresses": [{ + "label": "Home", + "street": "12 Mean Street", + "city": "Boston", + "links": { + "country": { + "type": "countries", + "id": "1" + } + } + }, { + "label": "Headquarters", + "street": "3−99−1 Nihonbashi, Chūō-ku", + "city": "Tokyo", + "links": { + "country": { + "type": "countries", + "id": "81" + } + } + }] +} +``` + ### Compound Documents To reduce the number of HTTP requests, servers **MAY** allow responses that From 88bb0284cadbfab52a991d0eb1b1d94e37e2d20b Mon Sep 17 00:00:00 2001 From: Kalle Tuure Date: Fri, 6 Mar 2015 14:22:52 +0200 Subject: [PATCH 2/3] Clarify wording on complex attr linking --- format/index.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/format/index.md b/format/index.md index 45d97d788..04cefcded 100644 --- a/format/index.md +++ b/format/index.md @@ -340,10 +340,10 @@ relationship as a string value rather than an object, is equivalent: The value of a complex attribute is allowed to be any valid JSON structure. -Complex attributes **MAY** contain references to resources. The relationships -are represented in the same way as links on resource objects. Therefore, any -JSON object in a complex attribute must reserve the `links` member to hold -relationship information. +A JSON object that constitutes or is contained in a complex attribute **MAY** +contain references to resources. The relationships are represented in the same +way as relationships on resource objects. Therefore, any JSON object in a complex +attribute must reserve the `links` member to hold relationship information. For example, a representation of a `people` resource might include an array of addresses embedded as a complex attribute: @@ -365,7 +365,7 @@ addresses embedded as a complex attribute: } }, { "label": "Headquarters", - "street": "3−99−1 Nihonbashi, Chūō-ku", + "street": "3-99-1 Nihonbashi, Chūō-ku", "city": "Tokyo", "links": { "country": { From e38697a7ee880c96e93f0ad3a6dcebadd96ee64a Mon Sep 17 00:00:00 2001 From: Kalle Tuure Date: Sun, 8 Mar 2015 20:15:07 +0200 Subject: [PATCH 3/3] Don't explain linking from complex attrs --- format/index.md | 47 ++++------------------------------------------- 1 file changed, 4 insertions(+), 43 deletions(-) diff --git a/format/index.md b/format/index.md index 04cefcded..8cbaaff9c 100644 --- a/format/index.md +++ b/format/index.md @@ -144,8 +144,10 @@ In addition, a resource object **MAY** contain any of these top-level members: Any other top-level member in a resource object represents an "attribute". An attribute may contain any valid JSON value. -If the value of an attribute is a JSON object or array, the member is called -a [complex attribute](#document-structure-complex-attrs). +If the value of an attribute is a JSON object or array, the member is called a +*complex attribute*. The value is allowed to be any valid JSON structure. +However, a JSON object that constitutes or is contained in a complex attribute +must reserve the `id`, `type`, `links`, and `meta` members for future use. Although has-one foreign keys (e.g. `author_id`) are often stored internally alongside other information to be represented in a resource object, these keys @@ -336,47 +338,6 @@ relationship as a string value rather than an object, is equivalent: // ... ``` -#### Complex Attributes - -The value of a complex attribute is allowed to be any valid JSON structure. - -A JSON object that constitutes or is contained in a complex attribute **MAY** -contain references to resources. The relationships are represented in the same -way as relationships on resource objects. Therefore, any JSON object in a complex -attribute must reserve the `links` member to hold relationship information. - -For example, a representation of a `people` resource might include an array of -addresses embedded as a complex attribute: - -```json -{ - "type": "people", - "id": "789", - "name": "Victor Shiroyama", - "addresses": [{ - "label": "Home", - "street": "12 Mean Street", - "city": "Boston", - "links": { - "country": { - "type": "countries", - "id": "1" - } - } - }, { - "label": "Headquarters", - "street": "3-99-1 Nihonbashi, Chūō-ku", - "city": "Tokyo", - "links": { - "country": { - "type": "countries", - "id": "81" - } - } - }] -} -``` - ### Compound Documents To reduce the number of HTTP requests, servers **MAY** allow responses that pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy