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

Allow bytes (non-json) message values #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

boimart1
Copy link

@boimart1 boimart1 commented Sep 12, 2022

In my use-case, message values are serialized protobuf messages which cannot be interpreted as JSON. As such, the line message.value = str(message.value) was turning a serialized message like b'test' into its string representation "b'test'". Upon consumption, json.dumps(message.value).encode() was further transforming the message, sending the bytes object b'"b'test'"' to the consumer, and as such the consumer could not parse the intended protobuf message at all.

This PR keeps the bytes object as-is if it couldn't be parsed as JSON. It only transforms it into its string representation in to_dict() if necessary, since this seems to be only place where it needs a JSON-compatible type/value.

(cherry picked from commit 202f91c5a4ac0151f166a3f5716d89acc68b35b8)
(cherry picked from commit 04abd2195c21559c64102a8c774671dba9e03d79)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant