-
Notifications
You must be signed in to change notification settings - Fork 58
Closed
Labels
/spec-v2Smth that is related to the next major version of the CloudEvents specSmth that is related to the next major version of the CloudEvents specwontfixThis will not be worked onThis will not be worked on
Description
Expected Behavior
JSON format spec section [#3.1.1] states
If the datacontenttype declares the data to contain JSON-formatted content, a JSON serializer MUST translate the data value to a JSON value, and use the member name data to store it inside the JSON representation. The data value MUST be stored directly as a JSON value, rather than as an encoded JSON document represented as a string.
from cloudevents.http import CloudEvent, to_json
import json
json.loads(
to_json(
CloudEvent(
attributes={"type": "my-type", "source": "my-source"},
data='{"a": "b"}',
)
)
)["data"] =={"a": "b"}
Actual Behavior
When an encoded json value is passed into the cloud even, when to_json
is invoked the resulting json object has an encoded json object in the data field and not a JSON representation as required.
from cloudevents.http import CloudEvent, to_json
import json
json.loads(
to_json(
CloudEvent(
attributes={"type": "my-type", "source": "my-source"},
data='{"a": "b"}',
)
)
)["data"] == '{"a": "b"}'
Specifications
- Platform: windows
- Python Version: python 3.8
Metadata
Metadata
Assignees
Labels
/spec-v2Smth that is related to the next major version of the CloudEvents specSmth that is related to the next major version of the CloudEvents specwontfixThis will not be worked onThis will not be worked on