cloudevents / sdk-ruby

Ruby SDK for CloudEvents
Apache License 2.0
42 stars 13 forks source link

fix!: Properly handle data when the content-type indicates JSON #57

Closed dazuma closed 3 years ago

dazuma commented 3 years ago

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:

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