Follow-up to #2621492: [meta] Maximize consistency with XML source plugin

Right now, the JSON source plugin takes a simple list of fields to retrieve from the same level/depth as the identifier:

  identifierDepth: 1
  fields:
    - sourceid
    - name

The XML source plugin equivalent permits labeling the source fields (this will be of more use when the migrate_tools front end is built out further, admittedly) and allowing them to have different names when used as source fields in the migration than they do in the JSON source:

  # Where the migrateable source data is relative to the document root.
  item_xpath: /response/position
  fields:
    machine_name:
      label: 'Unique position identifier'
      # Relative to the item_xpath
      xpath: sourceid
    friendly_name:
      label: 'Position name'
      xpath: name

So, I'd like to see those capabilities in the JSON source plugin, as well as the ability to specify a relative depth for the fields, for cases where we want to pull data embedded a little deeper (this should help reduce the need to extend the classes when JSON items aren't flat lists of data). Suppose we had JSON representing

$item = [
  'position' => [
      'sourceid' => 'vintner',
      'data' => ['name' => 'Vintner'],
    ],
];
  # Renamed for coding conventions, and to show this is the root of an item, not just the ID.
  item_depth: 1
  fields:
    machine_name:
      label: 'Unique position identifier'
      # The name of the field within the JSON, which we convert to 'machine_name' in the Row object.
      source: sourceid
    friendly_name:
      label: 'Position name'
      source: name
      # Relative to the item_depth - default is 0 thus not specified for sourceid.
      depth: 1

Comments

mikeryan created an issue. See original summary.

mikeryan’s picture

Status: Active » Closed (won't fix)

This module has been superseded by the json parser plugin in migrate_plus (which addresses this issue) and is no longer supported.