Move JSON encoding and decoding to the transport.