Define encodings for your types, use them to serialise and deserialise data.
encoding
Check-out the tutorial or the API.
tutorial
API
data-encoding