Implemented serialization of messages in json following the new protocol proposal with size prefix