How do I compare the contents of two Google Protocol Buffer messages for equality?

谁说我不能喝 提交于 2020-05-15 18:40:31

问题


I can't seem to find a comparison method in the API. So I have these two messages, and they have a lot of different values that sometimes drill down to more values (for example, I have a Message that has a string, an int, and a custom_snapshot, where custom_snapshot is comprised of an int, a string, and so on). I want to see if these two messages are the same. I don't want to compare each value one by one, since that will take a while, so I was wondering if there was a quick way to do this in Python?

I tried doing messageA.debugString() == messageB.debugString(), but apparently there is no debugString method that I could access when I tried. Any help would be appreciated. Thanks!


回答1:


protocol buffers have a method SerializeToString()

Use it to compare your messages.



来源:https://stackoverflow.com/questions/24296221/how-do-i-compare-the-contents-of-two-google-protocol-buffer-messages-for-equalit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!