MessagePack 有两个概念: type system and formats.
一、Type system:
1、Extension type(面向应用的扩展类型:由一个整型和一个字节数组构成)
MessagePack allows applications to define application-specific types using the Extension type. Extension type consists of an integer and a byte array where the integer represents a kind of types and the byte array represents data.
Applications can assign 0 to 127 to store application-specific type information.
MessagePack reserves -1 to -128 for future extension to add predefined types which will be described in separated documents.
[0, 127]: application-specific types
[-128, -1]: reserved for predefined types
说明:
例如在对一个java对象进行序列化的时候其实就是把这个对象的属性按bean定义顺序逐一构成一个array进行的编码;
例如对该bean进行序列化:
序列化后的十六进制为:9401a162a163c2
解读:上边说了,第一个int是由0~127构成的类型说明,此处为97
随后的“01”表示类型为int,值此处为1
随后的“a162”表示类型为fixstr,值此处为a(62)
随后的“a163”表示类型为fixstr,值此处为b(63)
随后的“c2”表示类型为boolean,值此处为false
疑问:在messagepack对于Formats的Overview中,fixstr 101xxxxx 0xa0-0xbf,这里是a1,那a2~bf又是表示什么呢?
且听下回分解 =。=