Protostuff or protobuf-java-format for encoding in different format

1,014 views
Skip to first unread message

extremeblue99

unread,
Apr 11, 2012, 5:20:24 PM4/11/12
to protobuf-java-format
I'm trying to decide on a framework to support multiple encoding
formats with protobuf since we want a more "standard" encoding scheme
than protobuf's native. It basically comes down to protostuff and
protobuf-java-format. I know protostuff has many more features than
just supporting different encoding schemes. I will most likely use
json and smile but will also want to add some new ones like a-xdr, asn.
1. It doesn't look too bad in either framework. Anyway, i just want
some thoughts from this group on how to best approach this. Thanks.

Philippe Laflamme

unread,
Apr 11, 2012, 11:30:19 PM4/11/12
to extremeblue99, protobuf-java-format
Hi,

Last I checked, protostuff required a custom schema to serialize/deserialize. I think the schema can be generated from the proto file. Otherwise, I think both are pretty similar... not sure about performance though.

Personally, I use protostuff to generate GWT "javascript overlays" for my proto messages and use protobuf-java-format to serialize to JSON. I didn't like the fact that I needed 2 different overlays, one for development, one for production, so I have a custom template for generating the overlays which matches the protostuff-java-format JSON format directly (mostly an issue with enums).

Hope that helps,
Philippe


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


extremeblue99

unread,
Apr 12, 2012, 2:58:44 AM4/12/12
to protobuf-java-format
Thanks for the comment. I don't know about before. protostuff compiler
can auto generate a schema specifically for protobuf via compiler
option java_v2protoc_schema:
* complements the generated code from the official C++ protoc
compiler.
* allows the existing protoc-generated code to be efficiently
serialized to json.

For example,

Person person = Person.newBuilder()
.setName("John Doe")
.setMotto("Speed kills!")
.setGender(Gender.MALE)
.build();

boolean numeric;
OutputStream out;
JsonIOUtil.writeTo(out, person, SchemaFoo.Person.WRITE, numeric);

SchemaFoo is auto generated from the .proto file.

http://code.google.com/p/protostuff/wiki/JsonSerialization#java_v2protoc_schema

Philippe Laflamme

unread,
Apr 12, 2012, 9:13:38 AM4/12/12
to extremeblue99, protobuf-java-format
(resending to the list)

Right, so the main difference between protostuff and protobuf-java-format is that the later does not require this schema. It uses the output of the proto compiler directly.

If you don't mind having these schema, then I suppose protostuff can provide more flexibility.

Philippe


Reply all
Reply to author
Forward
0 new messages