code: function (obj, returnType, encoding) {
      if (typeof obj !== 'object') {
        throw new TypeError('Value is not an object')
      }
      var returnValue = obj
      if (returnType !== 'obj') {
        returnValue = MessageUtils.objectToJson(obj)
        if (returnType === 'bin') {
          returnValue = MessageUtils.encode(returnValue, encoding)
        }
      }
      return returnValue
    }
docs: Convert an object to a returnType. If the returnType is 'obj', the supplied
  obj is returned. If the returnType is 'bin', the value is returned as a
  binary buffer, serialized as a JSON string. If the returnType is 'txt' (or
  anything else), the value is returned as a JSON-serialized string.
  @param {Object} obj - The object.
  @param {String} returnType - One of 'bin', 'obj', or 'txt'.
  @param {String} [encoding=utf8] - The encoding of the payload. (Unused
  unless the payloadType is 'bin'.)
  @returns {(Buffer|Object|String)} The value converted from the object.