Based on the Borsh serialization format I have created an easy to use TypeScript library that lets you conveniently serialize your classes into a compact binary representation. Later, you can deserialize this directly back directly into classes or using other languages, like with the Rust implementation borsh-rs. One of many reasons for using this library compared to using JSON is that you can have messages behave like Rust enums, rather than plain JS object that you have to do type checking with in order to determine what kind of object you are dealing with.TypeScript: https://github.com/dao-xyz/borsh-ts
Rust: https://github.com/near/borsh-rs