@@ -177,6 +177,52 @@ consider moving it into the specification as a core attribute. This means
177177that the extension mechanism/process can be used as a way to vet new
178178attributes prior to formally adding them to the specification.
179179
180+ ### JSON Extensions
181+
182+ As mentioned in the [ Attributes] ( json-format.md#2-attributes ) section of the
183+ [ JSON Event Format for CloudEvents] ( json-format.md ) specificatinon,
184+ CloudEvent extension attributes are serialized as siblings to the specification
185+ defined attributes - meaning, at the top-level of the JSON object. The
186+ authors of the specification spent a long time considering all options
187+ and decided that this was the best choice. Some of the rationale follows.
188+
189+ Since the specifications follow [ semver] ( https://semver.org/ ) , this
190+ means that new properties can be defined by future versions of the
191+ core specification without requiring a major version number change - as
192+ long as these properties are optional. In those cases, consider what an
193+ existing consumer would do with a new (unknown) top-level property. While
194+ it would be free to ignore it, since it is optional, in most cases it is
195+ believed that these properties would still want to be exposed to the
196+ application receiving those events. This would allow those applications to
197+ support these properties even if the infrastructure doesn't. This means
198+ that unknown top-level properties (regardless of who defined them - future
199+ versions of the spec or the event producer) are probably not going to be
200+ ignored. So, while some other specifications define a specific property
201+ underwhich extensions are placed (e.g. a top-level ` extensions ` property), the
202+ authors decided that having two different locations within an
203+ incoming event for unknown properties could lead to interoperability issues
204+ and confusion for developers.
205+
206+ Often extensions are used to test new potential properties of
207+ specifications prior to them being formally adopted. If there were an
208+ ` extensions ` type of property, in which this new property was serialized,
209+ then if that property were to ever be adopted by the core specification it
210+ would be promoted (from a serialization perspective) from the ` extensions `
211+ property to be a top-level property. If we assume that this new property
212+ will be optional, then as it is adopted by the core specification it will
213+ be just a minor version increment, and all existing consumers should still
214+ continue to work. However, consumers will not know where this property
215+ will appear - in the ` extensions ` property or as a top-level property.
216+ This means they might need to look in both places. What if the property
217+ appears in both place but with different values? Will producers need to place
218+ it in both places since they could have old and new consumers? While
219+ it might be possible to define clear rules for how to solve each of the
220+ potential problems that arise, the authors decided that it would be better
221+ to simply avoid all of them in the first place by only having one location
222+ in the serialization for unkown, or even new, properties. It was also
223+ noted that the HTTP specification is now following a similar pattern by
224+ no longer suggesting that extension HTTP headers be prefixed with ` X- ` .
225+
180226## Qualifying Protocols and Encodings
181227
182228The explicit goal of the CloudEvents effort, as expressed in the specification,
0 commit comments