MessagePack Java Jackson Dataformat 不使用 str8 数据类型的序列化

老的 msgpack-java(例如 0.6.7)并不支持 MessagePack str8 数据类型。

当你的希望的你的应用程序需要支持老的版本的话,你需要禁用这个数据类型,例如使用下面的语句:

MessagePack.PackerConfig config = new MessagePack.PackerConfig().withStr8FormatSupport(false);
ObjectMapper mapperWithConfig = new ObjectMapper(new MessagePackFactory(config));
// This string is serialized as bin8 type
byte[] resultWithoutStr8Format = mapperWithConfig.writeValueAsBytes(str8LengthString);

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

猜你喜欢

转载自www.cnblogs.com/huyuchengus/p/11330460.html