JSON and CBOR encoding

TODO

Transactional/atomic changes.