Skip to content

Commit d7ae79c

Browse files
evankandersonDoug Davis
authored andcommitted
Fix up JSON type mappings (#496)
* Fix up JSON type mappings Signed-off-by: Evan Anderson <[email protected]> * Fix type mapping for AMQP Signed-off-by: Evan Anderson <[email protected]> * Add `data` to AMQP. Signed-off-by: Evan Anderson <[email protected]> * Add payload data to amqp-format.md Signed-off-by: Evan Anderson <[email protected]> * Update AMQP data encoding per discussion in #492 Signed-off-by: Evan Anderson <[email protected]>
1 parent be24089 commit d7ae79c

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

amqp-format.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
## Abstract
44

5-
The AMQP Format for CloudEvents defines how event attributes are expressed in
6-
the [AMQP 1.0 Type System][type-system].
5+
The AMQP Format for CloudEvents defines how event attributes and payload data
6+
are expressed in the [AMQP 1.0 Type System][type-system].
77

88
## Status of this document
99

@@ -13,7 +13,8 @@ This document is a working draft.
1313

1414
1. [Introduction](#1-introduction)
1515
2. [Attributes](#2-attributes)
16-
3. [References](#3-references)
16+
3. [Data](#3-data)
17+
4. [References](#4-references)
1718

1819
## 1. Introduction
1920

@@ -55,13 +56,13 @@ exceptions noted below.
5556

5657
| CloudEvents | AMQP |
5758
| ------------- | --------------------------- |
58-
| String | [string][amqp-string] |
59+
| Boolean | [boolean][amqp-boolean] |
5960
| Integer | [long][amqp-long] |
61+
| String | [string][amqp-string] |
6062
| Binary | [binary][amqp-binary] |
6163
| URI | [string][amqp-string] |
6264
| URI-reference | [string][amqp-string] |
6365
| Timestamp | [timestamp][amqp-timestamp] |
64-
| Any | See 2.3. |
6566

6667
A CloudEvents AMQP format implementation MUST allow for attribute values to be
6768
convertible from/to their canonical CloudEvents string representation. For
@@ -88,14 +89,21 @@ any revision of such a specification, MUST also define explicit mapping rules
8889
for all other event formats that are part of the CloudEvents core at the time of
8990
the submission or revision.
9091

91-
### 2.3. Mapping Any-typed Attributes
92+
## 3. Data
93+
94+
Before encoding, the AMQP serializer MUST first determine the runtime data type
95+
of the data content. This may be determined by examining the data for characters
96+
outside the UTF-8 range or by consulting the `datacontenttype` attribute.
97+
98+
If the implementation determines that the type of the data is binary, the value
99+
MUST be stored in the payload as a single [AMQP data][amqp-data] section.
92100

93-
`Any`-typed CloudEvents values can either hold a `String`, or a `Binary` value,
94-
or a `Map`. `Map` entry values are also `Any` typed. AMQP's type system natively
95-
represents dynamic typing in its [type system encoding][type-system-encoding],
96-
and therefore immediately allows for the required variant type representation.
101+
For other types (non-binary data without a `datacontenttype` attribute), the
102+
implementation MUST translate the data value into an [AMQP type
103+
system][type-system] value and the value MUST be stored in an [AMQP
104+
value][amqp-value] section.
97105

98-
## 3. References
106+
## 4. References
99107

100108
- [RFC2046][rfc2046] Multipurpose Internet Mail Extensions (MIME) Part Two:
101109
Media Types
@@ -109,21 +117,25 @@ and therefore immediately allows for the required variant type representation.
109117
https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html
110118
[type-system-encoding]:
111119
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#section-encodings
112-
[amqp-string]:
113-
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-string
120+
[amqp-boolean]:
121+
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-boolean
114122
[amqp-long]:
115123
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-long
124+
[amqp-string]:
125+
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-string
116126
[amqp-binary]:
117127
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-binary
118128
[amqp-timestamp]:
119129
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-timestamp
120-
[amqp-map]:
121-
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-map
122-
[amqp-describedtype]:
123-
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#doc-idp38080
130+
[amqp-data]:
131+
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-data
132+
[amqp-value]:
133+
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-value
124134
[rfc2046]: https://tools.ietf.org/html/rfc2046
125135
[rfc2119]: https://tools.ietf.org/html/rfc2119
126136
[rfc4627]: https://tools.ietf.org/html/rfc4627
127137
[rfc4648]: https://tools.ietf.org/html/rfc4648
128138
[rfc6839]: https://tools.ietf.org/html/rfc6839#section-3.1
129139
[rfc8259]: https://tools.ietf.org/html/rfc8259
140+
[oasis-amqp-1.0]:
141+
http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-overview-v1.0-os.html

json-format.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ with exceptions noted below.
6262

6363
| CloudEvents | JSON |
6464
| ------------- | -------------------------------------------------------------- |
65-
| String | [string][json-string] |
65+
| Boolean | [boolean][json-bool]
6666
| Integer | [number][json-number], only the `int` component is permitted |
67+
| String | [string][json-string] |
6768
| Binary | [string][json-string], [Base64-encoded][base64] binary |
6869
| URI | [string][json-string] following [RFC 3986][rfc3986] |
6970
| URI-reference | [string][json-string] following [RFC 3986][rfc3986] |
7071
| Timestamp | [string][json-string] following [RFC 3339][rfc3339] (ISO 8601) |
71-
| Any | [JSON value][json-value] |
7272

7373
Extension specifications MAY define diverging mapping rules for the values of
7474
attributes they define.
@@ -297,6 +297,7 @@ also valid in a request):
297297
https://www.iana.org/assignments/media-types/application/geo+json-seq
298298
[json-object]: https://tools.ietf.org/html/rfc7159#section-4
299299
[json-seq]: https://www.iana.org/assignments/media-types/application/json-seq
300+
[json-bool]: https://tools.ietf.org/html/rfc7159#section-3
300301
[json-number]: https://tools.ietf.org/html/rfc7159#section-6
301302
[json-string]: https://tools.ietf.org/html/rfc7159#section-7
302303
[json-value]: https://tools.ietf.org/html/rfc7159#section-3

0 commit comments

Comments
 (0)