Over the years, I have tried several options or serialization / deserialization, including JSON, XML, SOAP, protobuf and some others that I am confused to name here :-)
Currently, we use JSON encoding almost exclusively to transmit Java-to-Java and JS-to-Java, and even to store internal data (if the amount of binary data does not make the JSON format too inefficient). Advantages of JSON are simplicity, low weight, both in terms of payload and complexity of implementation and accessibility of serialization solutions in all languages ​​affected by us. It also helps to have a “standard” save structure.
Jackson has been working well for us lately. Jabsorb also has a nice serialization package (de).
Versions: JSON does not have native version support ( Avro may have something), so you must run your own. It is usually recommended to maintain the numbering scheme of major / minor versions: major version numbers are incompatible, minors are backward compatible, so client 1.2 can talk to server 1.5, but not to server 2.1.
Gotchas:
- It is sometimes difficult to convert Java generators such as TreeMap.
- Some implementations may embed default implementation class names, making the protocol less resilient. You might want to do nothing more by continuing with the wire.
source share