Using a JSON encoder for the messages