how to translate protobuf object to hash in python?

1,857 views
Skip to first unread message

龟腚

unread,
Dec 28, 2009, 9:34:17 PM12/28/09
to prot...@googlegroups.com
hi, i am a protobuf user also python user
and i want to translate protobuf object to python Dict object (or call it hash?)
its because i was developing a web gate witch query data from intranet's ice server and got the data in protobuf type 
then i translate it to Dict object and return it to internet user as in json format.
any advice or suggestion is welcom

--
welcom to gtalk me
http://hi.baidu.com/jyf1987

Pavel Shramov

unread,
Dec 29, 2009, 1:04:21 AM12/29/09
to 龟腚, prot...@googlegroups.com
On Tue, Dec 29, 2009 at 10:34:17AM +0800, 龟腚 wrote:
> hi, i am a protobuf user also python user
> and i want to translate protobuf object to python Dict object (or call it
> hash?)
> its because i was developing a web gate witch query data from intranet's ice
> server and got the data in protobuf type
> then i translate it to Dict object and return it to internet user as in json
> format.
> any advice or suggestion is welcom
I've created JSON serialilzation/deserialization routines for PB messages in
my RPC project [1]. Usage is simple -- import file [2] and if one of JSON
implementations (simplejson or cjson) are available You'll be able to call
SerializeToJSON and ParseFromJSON methods.

Pavel

--
[1] http://grid.pp.ru/wiki/pbufrpc#_json_wire_format
[2] http://grid.pp.ru/cgit/psha/pbufrpc/tree/pbufrpc/json.py

Zheng Xu

unread,
Nov 23, 2015, 1:04:04 PM11/23/15
to Protocol Buffers, jyf...@gmail.com
The ProtoText package might help you. 


It does efficient in-place dict-like operation to python protobuf object. 
Reply all
Reply to author
Forward
0 new messages