Previously, if the datacontenttype indicated JSON, the HTTP Binary decoder would not parse it but create CE objects containing the JSON-formatted string. This was inconsistent with the behavior of JSON structured decoding, and also caused incorrect round-tripping of JSON data content if the data was a JSON string rather than a JSON object.
This PR:
Fixes the HTTP-Binary decoder so it parses JSON content-types and exposes the data attribute as a JSON value.
Ensures that a CE with a string-valued data attribute and a JSON content-type, is semantically treated as a JSON string, and is "serialized" as such when encoding as HTTP-Binary.
Updates the HTTP-Binary decoder so it raises the new CloudEvents::NotCloudEventError (rather than returning nil) if given an HTTP request that does not appear to be a CloudEvent. This is a breaking change.
It also makes some adjustments to the format interface, standardizing and documenting the interface, transferring responsibility for content type handling to the format object, and adjusting JsonFormat to conform. It also makes some lower-level conversion methods in HttpBinding private. These involve breaking changes to some public interfaces, but not ones that are expected to be in widespread use at this point.
Previously, if the
datacontenttype
indicated JSON, the HTTP Binary decoder would not parse it but create CE objects containing the JSON-formatted string. This was inconsistent with the behavior of JSON structured decoding, and also caused incorrect round-tripping of JSON data content if the data was a JSON string rather than a JSON object.This PR:
data
attribute as a JSON value.data
attribute and a JSON content-type, is semantically treated as a JSON string, and is "serialized" as such when encoding as HTTP-Binary.CloudEvents::NotCloudEventError
(rather than returningnil
) if given an HTTP request that does not appear to be a CloudEvent. This is a breaking change.It also makes some adjustments to the format interface, standardizing and documenting the interface, transferring responsibility for content type handling to the format object, and adjusting JsonFormat to conform. It also makes some lower-level conversion methods in HttpBinding private. These involve breaking changes to some public interfaces, but not ones that are expected to be in widespread use at this point.
See also https://github.com/cloudevents/spec/issues/558