JSON转MsgPack概念工具
输入JSON数据,查看每个值的MsgPack类型映射关系,估算MsgPack编码后大小,模拟十六进制查看二进制输出,帮助理解MsgPack二进制格式。
模拟十六进制查看 (MsgPack Binary)
注意: 这是概念模拟,真实MsgPack编码由具体语言库实现。
MsgPack格式参考表
| MsgPack类型 | 格式代号 | JSON对应 | 说明 | 最小字节 |
| nil | 0xc0 | null | 空值 | 1 |
| false | 0xc2 | false | 布尔假 | 1 |
| true | 0xc3 | True | 布尔真 | 1 |
| positive fixint | 0x00 - 0x7f | number(0-127) | 正整数(单字节) | 1 |
| fixint | 0xe0 - 0xff | number(-32~-1) | 负整数(单字节) | 1 |
| uint8 | 0xcc | number(0-255) | 8位无符号整数 | 2 |
| uint16 | 0xcd | number(0-65535) | 16位无符号整数 | 3 |
| uint32 | 0xce | number | 32位无符号整数 | 5 |
| uint64 | 0xcf | number | 64位无符号整数 | 9 |
| int8 | 0xd0 | number(-128~127) | 8位有符号整数 | 2 |
| int16 | 0xd1 | number | 16位有符号整数 | 3 |
| int32 | 0xd2 | number | 32位有符号整数 | 5 |
| int64 | 0xd3 | number | 64位有符号整数 | 9 |
| float32 | 0xca | number(浮点) | 32位IEEE 754 | 5 |
| float64 | 0xcb | number(浮点) | 64位IEEE 754 | 9 |
| fixstr | 0xa0-0xbf | string(0-31B) | 定长字符串 | 1+len |
| str8 | 0xd9 | string | 8位长度字符串 | 2+len |
| str16 | 0xda | string | 16位长度字符串 | 3+len |
| str32 | 0xdb | string | 32位长度字符串 | 5+len |
| fixarray | 0x90-0x9f | array(0-15) | 定长数组 | 1+items |
| array16 | 0xdc | array | 16位长度数组 | 3+items |
| array32 | 0xdd | array | 32位长度数组 | 5+items |
| fixmap | 0x80-0x8f | object(0-15) | 定长映射 | 1+pairs |
| map16 | 0xde | object | 16位长度映射 | 3+pairs |
| map32 | 0xdf | object | 32位长度映射 | 5+pairs |
| bin8 | 0xc4 | Base64 string | 8位二进制 | 2+len |
| bin16 | 0xc5 | Base64 string | 16位二进制 | 3+len |