Shezan Baig Shezan Baig - 1 year ago 66
JSON Question

compact binary representation of json

Are there any compact binary representations of JSON out there? I know there is BSON, but even that webpage says "in many cases is not much more efficient than JSON. In some cases BSON uses even more space than JSON".

I'm looking for a format that's as compact as possible, preferably some kind of open standard?

Answer Source

Yes: Smile data format. It is relatively new as far as data formats go, has public Java implementation, C version in the works at github (libsmile). It has benefit of being more compact than JSON (reliably), but being 100% compatible logical data model, so it is easy and possible to convert back and forth with textual JSON.

For performance, you can see jvm-serializers benchmark, where smile competes well with other binary formats (thrift, avro, protobuf); sizewise it is not the most compact (since it does retain field names), but does much better with data streams where names are repeated.

It is being used by some projects (like Elastic Search, Protostuff-rpc supports it), although not as widely as say Thrift.

EDIT (Dec 2011) -- there are now also libsmile bindings for PHP, Ruby and Python, so language support is improving. In addition there are measurements on data size; and although for single-record data alternatives (Avro, protobuf) are more compact, for data streams Smile is often more compact due to key and String value back reference option.