javascript protocol buffers encoder

284 views
Skip to first unread message

alf

unread,
Jan 4, 2010, 5:30:44 PM1/4/10
to Protocol Buffers
There are any away to encode data to protobuffer message directly from
javascript ?

what do you think about this idea. load data,
encode,
convert to string,
send to server,
receive to serve,
convert string to bytes,
decode to pb message

any opensource tools.

many thanks.

Kenton Varda

unread,
Jan 4, 2010, 8:30:17 PM1/4/10
to alf, Protocol Buffers
Two problems with encoding/decoding binary messages in javascript:
- Javascript doesn't have a usable "array of bytes" type.
- Even if it did, encoding/decoding would be painfully slow and would require downloading a lot of code to the client.

A better idea is to encode messages in JSON format.  There's at least one (third-party) JSON codec for protocol buffers here:

It's easy to write your own JSON codec against any of the official protobuf implementations using the reflection interfaces.  Look at how TextFormat is implemented in each language for an example.




--

You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.



Reply all
Reply to author
Forward
0 new messages