-
Notifications
You must be signed in to change notification settings - Fork 0
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 encode from JSON to base64 Protobuf #1
Comments
You can do this. I believe there is a python package called blackboxprotobuf I have used for it. Let me see if I can find a code example in a few hours. |
Thank you for this reference, it seems to be quite what I was looking for. import blackboxprotobuf
import base64
import json
data = base64.b64decode('EgIQAQ==', altchars = '-_')
message, typedef = blackboxprotobuf.decode_message(data)
print(json.dumps(message, indent = 4))
print(json.dumps(typedef, indent = 4))
##
message = {
'2': {'2': 1}
}
typedef = {
'2': {
'type': 'message',
'message_typedef': {
'2': {
'type': 'int'
}
},
'field_order': [
('2', 0)
]
}
}
data = blackboxprotobuf.encode_message(message, typedef)
print(base64.b64encode(data, altchars = b'-_').decode('ascii')) |
This was referenced Sep 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this Wiki section you give a method to decode a received base64 Protobuf but as I detail in this issue I would like to write in my source code meaningful JSON parameters like:
instead of the blacker box:
EgIQAQ==
but still be able to generate such base64 protobuf on the fly from above JSON. Is there any way to do so, even guessing the schema or so?The text was updated successfully, but these errors were encountered: