Skip to content

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

Description

@stamog

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

Activity

  1. pcaldeira-md commented on Dec 12, 2022

    @pcaldeira-md

    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.

  2. xSAVIKx commented on Dec 12, 2022

    @xSAVIKx
    Member

    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 :-)

  3. pcaldeira-md commented on Dec 12, 2022

    @pcaldeira-md

    Great, thanks! 🙏

  4. xSAVIKx commented on Dec 15, 2022

    @xSAVIKx
    Member

    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.

  5. MaryamTaj commented on Nov 26, 2023

    @MaryamTaj

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions