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

Add json support with binary fields via base64 encoding #351

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

Conversation

dominikandreas
Copy link

My use-case requires capnp messages to (also) be serialized to json and deserialized from json. This PR adds support for this by converting binary data to a base64 encoded string, which is compatible with json.

The implementation is non-breaking, the previous behavior stays the same, but can be controlled via a msg.to_dict(encode_binary_as_base64=True).

I realize this might be a rare use-case but doesn't hurt to have it as a feature and at least in my case it's useful to have json as a fallback solution in the communication stack for debugging purposes.

Copy link
Collaborator

@haata haata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub Actions seem to be misbehaving. I'm looking into this.


@pytest.fixture
def blob_schema():
return capnp.load(os.path.join(this_dir, "blob_test.capnp"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forget to add blob_test.capnp to the commit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I've added it now

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.

2 participants