开发者

Serialize objects like Google Gson but into compact binary format?

I'm hoping there is a library that allows serialization of J开发者_高级运维ava POJOs, in a similar manner to Google's excellent Gson library.

However, I need the serialized format to be extremely compact (they need to fit into individual UDP packets), and so I'm concerned that serializing to JSON would be wasteful, and would prefer a binary format.

Is there such a thing?


Use Hessian instead. If you want to save some more space, decorate its stream with GZipOutput/Input Stream


Have you tried the default serialization format? It's binary, but not cross-language.

Maybe gzipped JSON could work.

Or you could look into protocol buffers


Some days ago I found BSON which claims to be a simple binary representation of JSON. I did not try this, but from its FAQ, it is not always more compact than JSON (small numbers use more space), but easier (quicker) to parse and produce. If you have known data types to transmit, other protocols could be more efficient (in terms of space, at least) than this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜