convert python object to protocol buffer object

Viewed 432

I have a django app up and running.
We have to support serialisation via protobuf.
For achieving the same we want to do minimum changes to our codebase and hence what we are doing is keeping the code as is which creates a python object returns json.
We have created a .proto file with the same expected format and and compiled the same. Now at the time of returning the response, i want to convert the python object into protobuf object.

I am trying to do this via code:

response = proto_object(**result)

This results in following error:

ValueError: Field name must be a string

Can somebody tell us what is wrong with above initialisation of protobuf and also the right way of achieving this.

I will share the .proto file if that is of any use.

0 Answers
Related