fix!: Properly handle data when the content-type indicates JSON #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 cloudevents/spec#558