MessagePack Java Jackson serialization and deserialization POJO array type used and MessagePack msgpack-java: maintaining compatibility 0.6

In msgpack-java 0.6 or earlier versions, POJO be serialized and deserialized in MessagePack the array variable.

Order of the variables is based on the internal order of the Java class variables, this method was originally one of the native sequence, but can cause problems. It causes these problems is in the order of internal variables of Java objects and Java implementation of the order can not guarantee full agreement.

From another perspective, using jackson-databind for serialization and deserialization mode is POJO based Key-Value pairs. Thus j ackson-dataformat-msgpack manner POJO process is the same. Therefore, it leads to the msgpack-java: 0.6 or earlier versions are not compatible at the time of the POJO serialization and de-serialization.

If you want to use the new version with msgpack-java: 0.6 POJO or handled the same way earlier versions, you can use  JsonArrayFormat. Specific methods are as follows:

ObjectMapper objectMapper =  new  ObjectMapper( new  MessagePackFactory());
objectMapper.setAnnotationIntrospector( new  JsonArrayFormat());

https://www.cwiki.us/display/Serialization/MessagePack+Jackson+Dataformat

Guess you like

Origin www.cnblogs.com/huyuchengus/p/11330357.html