toJSON(key) {
    if (key) {
      return super.toJSON(key);
    }

    let jsonData = super.toJSON();

    let scoped = parseScoped(this.name);

    // Allowing for scoped names, get the object in the JSON structure that corresponds
    // to this FixturifyProject.
    let container = scoped ? jsonData[scoped.scope][scoped.name] : jsonData[this.name];

    if (this._referenceDependencies || this._referenceDevDependencies) {
      let pkg = JSON.parse(container['package.json']);

      if (this._referenceDependencies) {
        if (!pkg.dependencies) {
          pkg.dependencies = {};
        }

        Object.assign(pkg.dependencies, this._referenceDependencies);
      }

      if (this._referenceDevDependencies) {
        if (!pkg.devDependencies) {
          pkg.devDependencies = {};
        }

        Object.assign(pkg.devDependencies, this._referenceDevDependencies);
      }

      container['package.json'] = JSON.stringify(pkg, undefined, 2);
    }

    // an optimization to remove any node_modules declaration that has nothing in it,
    // to avoid creating extra directories for no reason.
    if (container['node_modules'] && Object.keys(container['node_modules']).length === 0) {
      delete container['node_modules'];
    }

    return jsonData;
  }
Convert the object into a data structure suitable for passing to `fixturify`.

@param {String} key optional key. If specified, the object will be run through toJSON, then the given
property extracted and returned.
@returns {Object} the `toJSON` value of the object (wrapped) or the toJSON value of the specified field
(not wrapped.)