Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to_structured can't control NON-ASCII chars #206

Open
stamog opened this issue Nov 30, 2022 · 5 comments
Open

Method to_structured can't control NON-ASCII chars #206

stamog opened this issue Nov 30, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@stamog
Copy link

stamog commented Nov 30, 2022

Expected Behavior

I am using to_structured() but there are non-ascii symbols that I want to have included. I cannot alter its behaviour.

Actual Behavior

to_structured method returns them in the form of '\u00'

Steps to Reproduce the Problem

  1. Try to pass an event containing a non-ascii symbol (Ø, ü, etc.)
  2. Print the result

Specifications

  • Python 3.7.15
  • cloudevents 1.7.1
@pcaldeira-md
Copy link

Could anyone take a look at this? It would be nice to be able to pass a parameter like ensure_ascii=False on the methods serializing the cloud events into a JSON format.

@xSAVIKx
Copy link
Member

xSAVIKx commented Dec 12, 2022

Hey, sorry, I seemed to miss this one. I'll try to spend some time over the next couple of days, but no ETA. PRs are very welcome though :-)

@pcaldeira-md
Copy link

Great, thanks! 🙏

@xSAVIKx
Copy link
Member

xSAVIKx commented Dec 15, 2022

OK, this is unfortunately not possible right now as well as it is not possible to modify any JSON-related conversions.

I'd very much like to support ensure_ascii, but it will also require support for all the other possible parameters. And also this kinda forces both producer and consumer to be aware of ASCII encoding while in Python at least json.dumps and json.loads have ensure_ascii=True by default.

I believe SDK should support more than just a couple of params but IDK when this can be implemented. Ideally, I'd like to provide a way to just supply custom to_json and from_json implementations throughout the whole SDK. This allows for achieving any required flexibility.

@MaryamTaj
Copy link

@xSAVIKx I am interested in working on this issue, and I am trying to understand it a little better.
In the comment above, you mentioned that it would be ideal to have a custom to_json, and from_json implementation throughout the whole SDK. However, in the link below, doesn't the data_marshaller parameter act as a custom implementation?

:param data_marshaller: Callable function which will cast `event.data`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants