code: function(data, convertCaseOptions) {
  
      let converted;
  
      if (_.isArray(data) || _.isPlainObject(data)) {
        converted = _.transform(data, (result, value, key) => {
          if (_.isArray(value) || _.isPlainObject(value)) {
            result[this._convertCase(key, convertCaseOptions)] = this._convertCase(value, convertCaseOptions);
          } else {
            result[this._convertCase(key, convertCaseOptions)] = value;
          }
        });
      } else {
        switch (convertCaseOptions) {
        case 'snake_case':
          converted = _.snakeCase(data);
          break;
        case 'kebab-case':
          converted = _.kebabCase(data);
          break;
        case 'camelCase':
          converted = _.camelCase(data);
          break;
        default:
          converted = data;
          break;
        }
      }
  
      return converted;
    }
docs: Code inspired from the MIT licenced module https://github.com/danivek/json-api-serializer