JSON alternative with packed data: MessagePack
Posted: Sun Aug 01, 2021 12:55 pm
This repo is a MicroPython implementation of the MessagePack protocol. Of the various options for serialising data, ujson and MessagePack are arguably the easiest to use. While ujson produces human-readable data, MessagePack produces binary bytes data, achieving substantial packing in the process. It has the following features in common with ujson:
- Ease of use: unlike Protocol Buffers no schema is required.
- The data structure can change dynamically (unlike many binary schemes).
- Data packing comparable to other binary schemes.
- Ease of extension. The repo includes a module which extends support to tuple, set and complex types. It can readily be extended to support other native and library types.
- A class decorator enables user classes to be written so that instances can packed and unpacked in exactly the same way as native types.
- The module has support for asynchronous decoding of data which arrives on a slow or sporadic interface such as a UART or a socket.